ruby on rails - f.select not preselecting value while editing -


i have field state_id using select dropdown:

= form.select :state_id, options_for_select(states), {}, prompt: 'select state' 

but while editing form doesn't preselect current value of state_id. know can pass :selected param pass default selected value:

options_for_select(states, @object.state_id) 

but guide suggest don't need use options.

can tell me doing wrong?

note: it's nested attribute , other fields working fine f.text_field not f.select.

you can try out.

= select_tag "state_id", options_from_collection_for_select(states, "id", "name",@object.state_id), prompt: "select state", placeholder: "select state"

hope it'll job you.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -