Could someone point me to a quick version of how to use rails radio buttons? Is it in one of the tutorials, or is there a sample of rhtml that you could make available? I''ve looked at the rails api site, but while it''s really useful, I''m finding it to be a little short on examples... thanks!
I''m using them in a partial form, like this, where ''test'' is the model, ''button_enabled'' is a field in the db, and ''1'' and ''0'' are the values. after that, the ''checked'' => ''checked'' is just an option to have a button pre-selected in the html. true<%= radio_button(''test'', ''button_enabled'', ''1'') %> false<%= radio_button(''test'', ''button_enabled'', ''0'', ''checked'' => ''checked'') %> hope that helps.>> Could someone point me to a quick version of how to use rails radio >> buttons? Is it in one of the tutorials, or is there a sample of rhtml that >> you could make available? I''ve looked at the rails api site, but while >> it''s really useful, I''m finding it to be a little short on examples... >> thanks!-- -- Ian Kennedy http://www.fiftymillimeter.com
Here''s something, Steve. This is contrived. Normally, rather than an explicit loop over fixed values, you''d likely reference an associated table. <% @dummy = User.new %> <% for gender in [''male'',''female''] %> <label for="user_gender"><%= gender %>:</label> <%= radio_button(:user,:gender,gender) %><br> <% end %> Where gender_helper in app/helpers/application_helper.rb looks like this: def gender_helper return [''male'',''female''] end Make sure they''re actually inside a FORM element, of course! :-) -- -- Tom Mornini On Oct 10, 2005, at 2:25 PM, Steve Enzer wrote:> Could someone point me to a quick version of how to use rails radio > buttons? Is it in one of the tutorials, or is there a sample of > rhtml that > you could make available? I''ve looked at the rails api site, but while > it''s really useful, I''m finding it to be a little short on examples... > thanks! > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails