title: Rails - Select tag not pre-selected after Form's validation fail
body: <p>I have select tag</p>
  
  <pre><code> &lt;%= f.select :gender, ["M", "F"], include_blank: "---" %&gt;
  </code></pre>
  
  <p>If other field has error, the select tag will be reset to "---" even though I have picked an option before.</p>
  
  <p>The solution that I found is using <code>collection_select</code> which takes a ActiveRecord Model to be the option-value pair.</p>
  
  <p>Is there other way to do this?</p>
  
  <p>Thanks</p>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>The answer from @Micah is correct but since my form is Nested, it's different syntax.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;%= f.fields_for :users do |ff| %&gt;
    ...
    &lt;%= ff.select :gender, ["M", "F"], include_blank: "---",
          selected: ff.object.gender ? ff.object.gender : ""  %&gt;
    ...
  &lt;% end %&gt;
  </code></pre>