title: Rails 4: Set enum field through FactoryGirl attributes
body: <p>I have a Model that has an enum as attribute.</p>
  
  <pre><code>class ApplicationLetter &lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :event
  
    validates :user, :event, presence: true
  
    enum status: {accepted: 1, rejected: 0, pending: 2}
  
  end
  </code></pre>
  
  <p>As well as a factory that generates this model and sets a value for the enum</p>
  
  <pre><code>FactoryGirl.define do
    factory :application_letter do
      motivation "motivation"
      user
      event
      status :accepted
    end
  end
  </code></pre>
  
  <p>In a controller test I want to get valid attributes through the factory</p>
  
  <pre><code>let(:valid_attributes) { FactoryGirl.build(:application_letter).attributes }
  </code></pre>
  
  <p>and create a application with these attributes.</p>
  
  <pre><code>application = ApplicationLetter.create! valid_attributes
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <blockquote>
    <p>ArgumentError:
            '1' is not a valid status</p>
  </blockquote>
  
  <p>Why is status interpreted as string? If I change the status in the factory I get the same error, but with the right corresponding number.</p>