rails, simple_form, how to set selected index of a collection when page loaded?
Have you tried to use the :selected => option?
:selected => selected_country_id
So,
= f.input :country_id, :collection => all_countries, :selected => selected_country_id
This will work perfectly !!!
Cheers!
I know this has been answered, but I came here looking for a similar solution for a collection of check boxes. For posterity, here's how you do it:
<%= f.input :country_ids, :as => :check_boxes, :collection => [['USA', :USA], ['Japan', :JPN]], :checked => [:JPN], :include_hidden => false %>
Hope this helps someone.