Search code examples
ruby-on-railscarmen

How to pre select a state in Rails Carmen state_select


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'%>

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.