From: Rick DeNatale Date: 2008-01-28T09:17:25+09:00 Subject: Re: Getting NameError when trying to create a form with multiple of the same object On 1/27/08, laredotornado wrote: > Hi, > > I'm trying to create a form where a user can submit 5 of the same > object (named "ec_line_item" with attributes "item_number" and > "comments"). I'm doing something wrong because I'm getting this > error: > > NameError in Order#start > Showing app/views/order/start.rhtml where line #15 raised: > `@ec_line_item[i]' is not allowed as an instance variable name > > Here's my code: > > <% for i in 1 .. 5 %> > > > > I think that these two should be: -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/
<%= text_field("ec_line_item[i]", "item_number") %> td> > <%= text_field("ec_line_item[i]", "comments") %><%= text_field("ec_line_item", "item_number", "index" => i %> <%= text_field("ec_line_item", "comments", "index" => i %>