activerecord - Storing past relationships in rails -
i have item tracking system has item model has 1 many relationship invoice. meaning 1 invoice can have many items , item can belong 1 invoice.
i've run need return item stock system means setting delivered boolean field false, unless set invoice_id nil still show awaiting delivery customer , if nil system have no record of ever invoicing customer item.
the way can see of working have previous_invoices field stores ids of invoices been on. doing work items point of view item.previous_invoices make sense not show in invoice.items , items have been returned need db search condition.
i'd rather not use many many association tiny fraction of items returned need use table.
is there anyway of doing in rails or gem can handle finds on either side?
the relationship between invoice , item is many-to-many, , you're causing difficulty avoiding implementing such. cleanest solution invoiceitems table 'returned' field check when pull invoice items, perhaps conditional on invoice's habtm association items.
Comments
Post a Comment