title: How do you render previously selected option in Ruby on Rails?
body: <p>Currently I have a select tag with various options for the State in a from that I have.  When validations fail, the page is rendered again and the previously entered values in the textboxes don't get lost and are still present.  But the selected items aren't retained.  How do I code it so it is retained? </p>
  
  <p>View code:</p>
  
  <pre><code>= form_for @user do |f|
    = f.text_field :name
    = f.select :state, { "California" =&gt; "CA", "Texas" =&gt; "TX"} , :prompt =&gt; ''
    = f.submit "Submit"
  </code></pre>
  
  <p>Controller code:</p>
  
  <pre><code> def new
     @user = User.new
   end
  
   def create
      @user = User.new(params[:user])
      if @user.save
        redirect_to root_path
      else
        render 'new'
      end
    end
  </code></pre>
  
  <p>Thanks!</p>