I’m trying to provide our customers with a page where they can add up to
20 items to their cart in one form. The form simply has 20 rows with
each row containing a text input for product code and a text input for
I’ve tried having the controller create an array that has an object for
each row by looping through something like:
@new_items = Cart.new
and the controller is happy with that, but the template isn’t–it gives
an error like “@new_items is not allowed as an instance variable
I can get the whole thing working if I use non-model form objects in the
template, but then I lose the Rails error magic where it highlights any
errant fields and gives a message.
Why can I create Cart objects within an array in the controller, but not
use them in the template.
Or am I going about this completely wrong??
Any help is appreciated greatly.