Getting NameError when trying to create a form with multiple of the same object

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 %>

<%= text_field("ec_line_item[i]", "item_number") %> <%= text_field("ec_line_item[i]", "comments") %>
Item Number Comments
<% end %>

Any ideas? - Dave

On 1/27/08, laredotornado [email protected] wrote:

Here’s my code:

<% for i in 1 … 5 %>

I think that these two should be:

  <td><%= text_field("ec_line_item", "item_number", "index" => i 

%>


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

<%= text_field("ec_line_item[i]", "item_number") %> <%= text_field("ec_line_item[i]", "comments") %> <%= text_field(“ec_line_item”, “comments”, “index” => i %>