Forum: Ruby on Rails Radio Button Question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Kevin R. (Guest)
on 2007-06-22 00: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?


Rafael (Guest)
on 2007-06-25 13: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.



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


  <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.