问题
I'm trying to figure out how to set the selected option of a select box generated by SimpleForm. My code is along the lines of:
<%= simple_form_for(@user) do |f| %>
<%= f.association :store, default: 1 %>
Of course the default: 1
part does not work.
TIA
回答1:
Use the following:
selected: 1
回答2:
You can now use the following:
<%= f.association :store, selected: 1 %>
来源:https://stackoverflow.com/questions/10441061/how-to-set-default-selected-value-for-rails-simpleform-select-box