On Jan 23, 10:02 pm, laredotornado <laredotorn... / zipmail.com> wrote:
> Hi,
>
> I have several fields on my page, distinguished by numbers in the id:
>
> <% for i in 1 .. 5 %>
>         <tr><td>
>                 <table>
>                         <tr>
>                                 <td><%=
> text_field_tag("prescription_number" + i.to_s, "") %></td>
>                                 <td><%= text_field_tag("description" +
> i.to_s, "") %></td>
>                         </tr>
>                         <tr>
>                                 <td align="center">Prescription
> Number</td>
>                                 <td align="center">Description</td>
>                         </tr>
>                 </table>
>         </td></tr>
> <% end %>
>
> However, when I try and access the values in my controller,
>
>                 i = 0
>                 while params[:prescription_number + i.to_s] != nil and
> params[:description + i.to_s] != nil        # line 7
>                         session[:prescription_number + i.to_s] =
> params[:prescription_number + i.to_s]
>                         session[:description + i.to_s] =
> params[:description + i.to_s]
>                         i += 1
>                 end
>
> I get the error
>
>  NoMethodError in OrderController#confirm
> undefined method `+' for :prescription_number:Symbol
> RAILS_ROOT: ./script/../config/..
> Application Trace | Framework Trace | Full Trace
> /usr/local/apache2/htdocs/easyrx/app/controllers/order_controller.rb:
> 7:in `confirm'
>
> What is the correct way to access my parameter values?
>
> Thanks, - Dave

You're trying to concatenate a Symbol with a string. This IRB session
should help explain the difference:

irb(main):019:0> "Hello".class
=> String
irb(main):020:0> "Hello".intern
=> :Hello
irb(main):021:0> :Hello.class
=> Symbol
irb(main):022:0> :Hello + " World"
NoMethodError: undefined method `+' for :Hello:Symbol
        from (irb):22
irb(main):023:0> :Hello.to_s + " World"
=> "Hello World"