Forum: Ruby on Rails Forms with multiple item entry

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E51c6ae07e72cf04ef869868cb8eca6e?d=identicon&s=25 Jake Janovetz (Guest)
on 2006-01-22 03:22

I was wondering what would be the simplest/cleanest way to have a view
offer entry fields for several items (e.g. the "quantity" for items in a
shopping cart).

If I have a model such as "cart" which has_many "items", then I can use
"cart.items" to get an array of all of them.  Each item has a quantity,
so I'd have "cart.items[n].quantity" that I would like to display and
allow the user to enter.

What's the best way to present this (not so hard) and get it back into
the controller and save them.  Does each one have to be save()'ed
independently or is there a convenient 'array-save' of some sort?

This topic is locked and can not be replied to.