Question

What are the options I can pass in a state_select. I am trying to do :selected => state and its not working.

<%= f.state_select :state, 'US', {:prompt => '--Select One--', :selected => state}, :tabindex => autotab, :id => 'state_select, :state => state'%>
Était-ce utile?

La solution

I don't think you can use state_select to do it. You'll have to use select with the state_options_for_select function in order to enter your selected state:

<%= f.select :state, state_options_for_select(state_to_select, country_code) %>

That should get you there.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top