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

Discussion in 'Ruby' started by laredotornado, Jan 27, 2008.

  1. 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
     
    laredotornado, Jan 27, 2008
    #1
    1. Advertising

  2. 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' 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>


    --
    Rick DeNatale

    My blog on Ruby
    http://talklikeaduck.denhaven2.com/
     
    Rick DeNatale, Jan 28, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    955
    Roedy Green
    Jan 28, 2008
  2. Lambda
    Replies:
    2
    Views:
    420
    James Kanze
    Jul 16, 2008
  3. Thomas Watson Steen
    Replies:
    4
    Views:
    356
    Sisyphus
    Oct 4, 2004
  4. Dave Angel
    Replies:
    0
    Views:
    233
    Dave Angel
    Oct 24, 2012
  5. Vinay Sajip
    Replies:
    0
    Views:
    242
    Vinay Sajip
    Oct 24, 2012
Loading...

Share This Page