I copy the attributes of an object from model to another model, for example:
@estimate = Estimate.find(params[:estimate_id]) @invoice = Invoice.create(@estimate.attributes)
With this copy, only its attributes only copy, (Evaluate copies as a new invoice), but the model of the valuation model and invoice has a HABTM relationship to the "Item" model.
How to create a new @invoice object using Estimate and its Item together? Confused ...
Update:
- Estate: has_and_belongs_to_many: items (table valu_items) accepts_nested_attributes_for: items
- Account: has_and_belongs_to_many: items (table invoices_items) accepts_nested_attributes_for: items
- Element: belongs_to: belongs_to rating: invoice
Thanks.
Harry source share