title: How do I populate a select tag with a hash and properly save the value to the database?
body: <p>I'm attempting to setup a form for a model that contains a select box populated from a collection in the hash.</p>
  
  <p>Specifically, my employee model has a hash of roles:</p>
  
  <pre><code>ROLES = {1 =&gt; "Lead", 2 =&gt; "Engineer", 3 =&gt; "Intern" }
  </code></pre>
  
  <p>And a validator:</p>
  
  <pre><code>validates_presence_of :role
  </code></pre>
  
  <p>Ideally, I'd like to populate a select box in a form using this information. Something such as :</p>
  
  <pre><code>&lt;%= form_for @employee do |f| %&gt;
      &lt;%= label_tag :role, "Role" %&gt;
      &lt;%= f.select :employee, :role, Employee::ROLES %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Although I can display the values in the select box, the data isn't serialized. Instead, I receive the validation message that the "Role can't be blank."</p>
  
  <p>My controller's create method looks like this:</p>
  
  <pre><code>def create
    @employee = Employee.new(params[:employee])
    if @employee.save
      redirect_to employees_path, :notice =&gt; "Successfully created a new employee."
    else
      render :action =&gt; 'new'
    end
  end
  </code></pre>
  
  <p>Ultimately, my question is how do I populate the select box using the hash in the model and properly save the value of the select box to the column on the employee model in the database?</p>