I'm trying to set value in my simple_form
association
field:
<%= f.association :names %>
Now in this field I have some values, for example: John, Jack, Jerry.
How can I set, for example, default value Jerry
if I have params[:name] = Jerry
?
I tried this:
<%= f.association :names, selected: params[:name] %>
<%= f.association :names, input_html: { value: params[:name] } %>
But it doesn't work.
Try to use this code to set default value:
<%= f.association :names, default: params[:name] %>
See this link