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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top