1

This didn't work me: Rails - Default selected radiobutton in SimpleForm :collection

I am trying to have a default selection.

I have the following input in my form using simple_form

= f.association :collection_page

This generates a drop down with all the titles in my CollectionPage object.

Kinda like:

  • title1
  • title2
  • title3

lets say, @collection_page.title = title1

if I do:

= f.association :collection_page, as: :radio, :checked => @collection_page.title

title1 should be selected by default, but it isn't working for me.

Thank you in advance for your help.

Community
  • 1
  • 1
neo
  • 4,078
  • 4
  • 25
  • 41
  • This post might help http://stackoverflow.com/questions/9107751/rails-simple-form-how-to-set-default-selected-index-of-a-collection – MrYoshiji Jul 25 '14 at 18:23
  • Kinda seemed like it would work, but not working for me – neo Jul 25 '14 at 18:46
  • You must specify the value of radio button for `checked` key. `id` is the default value for radio buttons. So `checked: @collection_page.id` should work. – freemanoid Nov 04 '14 at 21:42

0 Answers0