سؤال

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