Frage

I have:

- [ 'here now', 'trip scheduled', 'planning a trip', 'already visited' ].each do |travel|
  %div.field.radio.small.snug.bind                  
    = f.radio_button :expected_travel, travel
    = label_tag "visitors_guide_request_expected_travel[#{travel}]", travel.titleize 

I need to have the radio button generated for 'here now' to be checked by default. What's the simplest way to do this?

War es hilfreich?

Lösung

you can pass in the :checked option to your radio_button:

= f.radio_button :expected_travel, travel, :checked => travel == 'here now'

That will check the button whose value is here now

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top