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

L

laredotornado

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' is not allowed as an instance variable name

Here's my code:

<% for i in 1 .. 5 %>
<tr><td>
<table>
<tr>
<td><%= text_field("ec_line_item", "item_number") %></
td>
<td><%= text_field("ec_line_item", "comments") %></td>
</tr>
<tr>
<td align="center">Item Number</td>
<td align="center">Comments</td>
</tr>
</table>
</td></tr>
<% end %>

Any ideas? - Dave
 
R

Rick DeNatale

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' is not allowed as an instance variable name

Here's my code:

<% for i in 1 .. 5 %>
<tr><td>
<table>
<tr>
<td><%= text_field("ec_line_item", "item_number") %></
td>
<td><%= text_field("ec_line_item", "comments") %></td>


I think that these two should be:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top