Radio Button Tag and hash @Params


I’ve a little problem using the Radio Button Tag.
I use the " @prove=MODEL.column_names() " to keep attribute names of a
table. After
i used this code to select a attribute subsets of them :

<% i=‘0’%>
<% for @obj in @prove %>
<% @key=’:key’+i%>
<%= radio_button_tag (@key,@obj) %>
<% i=i+‘1’ %>
<% end %>
<%= submit_tag (“calca”) %>
<%= end_form_tag %>

But when i come back to the controller, it’is impossible select the
right radio button value with the code :

@[email protected][@key];

The compiler don’t understand the Hash key that i used!.
The compiler want to use something such as: radio_button_tag (:key,@obj)

Some ideas?

<% @key=‘key’+i.to_s%>
or simply
<%= radio_button_tag (‘key’ + i.to_s,@obj) %>

also I guess ‘0’ and ‘1’ need to be replaced to 0 and 1 (no apostrophes)
otherwise you will get 0, 01, 011, 0111 etc. hashes

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs