문제

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