Forum: Ruby on Rails Radio Button Tag and hash @Params.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-24 18:02
Hi,

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 :

 @result=@params[@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?
7cda78d70ab775710f6fa24e0a5b68db?d=identicon&s=25 Emin Hasanov (Guest)
on 2006-03-24 20:31
(Received via mailing list)
try
<% @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 topic is locked and can not be replied to.