Had a problem with fields_for and accepts_nested_attributes_for
The invoice class has many invoice items, but they have to be displayed in a certain order. Originally I had an @invoice_items variable - but the form wasn't looking at this.
However, a genius on teh Ruby forum posted the following:
@invoice = Invoice.find(params[:id], :include => :invoice_items, :order "invoice_items.display_order")
When the invoice calls the invoice_items they are already in the object and in the right place. Now he has pointed it out to me, I get what it is - but don't think I would have come up with that on my own.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment