Forum: Ruby on Rails Radio Button Question

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.
9de0419d203d331bf033875fd718bbdc?d=identicon&s=25 Kevin R. (Guest)
on 2007-06-21 22:48
(Received via mailing list)
Hi all,

I'm a new Ruby on Rails user, and I'm trying to make a page with
several groups of 3 radio buttons. The user chooses one button from
each group, then clicks the save button, where each selection is
stored in the database. My question is how I can know which button was
selected - is there a method like get_checked_button, or do I have to
cycle through each group and see which of the three is checked? If the
latter is the case, how would I do that?

Thanks!

-Kevin
2808b5c359edcb77ec783e3793c8d381?d=identicon&s=25 Rafael (Guest)
on 2007-06-25 11:01
(Received via mailing list)
Hi Kevin,

actually I do this with javascript and a snippet of ruby
may somebody know a better way to do this.

regards

Rafael

--------------
case params[:apply_as]
  when "spontanous"
    @apply_as_spontanous  = 'checked'
  when "specific"
    @apply_as_specific    =  'checked'
  else
    @apply_as_specific    =  'checked'
end

------------

  <input type="radio" name="apply_as" id="apply_as" value="spontanous" <
%= "#{@apply_as_spontanous}" %> /> Spontanbewerbung
  <input type="radio" name="apply_as" id="apply_as" value="specific" <
%= "#{@apply_as_specific}" %> /> Bewerbung auf Offene Vakanz
This topic is locked and can not be replied to.