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

**URL:** <https://www.ruby-forum.com/t/getting-nameerror-when-trying-to-create-a-form-with-multiple-of-the-same-object/127278>\
**Category:** Ruby\
**Created:** [January 27, 2008, 6:25pm UTC](https://www.ruby-forum.com/t/getting-nameerror-when-trying-to-create-a-form-with-multiple-of-the-same-object/127278 "2008-01-27T18:25:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 27, 2008, 6:25pm UTC](https://www.ruby-forum.com/t/getting-nameerror-when-trying-to-create-a-form-with-multiple-of-the-same-object/127278/1 "2008-01-27T18:25:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 28, 2008, 1:18am UTC](https://www.ruby-forum.com/t/getting-nameerror-when-trying-to-create-a-form-with-multiple-of-the-same-object/127278/2 "2008-01-28T01:18:23Z")

</div>

On 1/27/08, laredotornado [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](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 %\> |
