title: Rails has_many association with a class that contains an enum
body: <p>I have a class <code>Shower</code> like so:</p>
  
  <pre><code>class Shower &lt; ActiveRecord::Base
    has_many :capabilities, dependent: :destroy
  
    //more code
  end
  </code></pre>
  
  <p>and a class <code>Capability</code>:</p>
  
  <pre><code>class Capability &lt; ApplicationRecord
    belongs_to :shower
  
    validates_presence_of :capability
  
    enum capability: [
      :mobile_supports_pusher,
      :hmi_supports_pusher
    ]
  end
  </code></pre>
  
  <p>Now I'm trying to create tests that make sure a created capability is valid or invalid:</p>
  
  <pre><code>require 'rails_helper'
  
  describe Capability do
    it "is invalid without required attributes" do
      capability = Capability.create
      expect(capability).to_not be_valid
      expect(capability.errors.keys).to eq [:capability]
    end
  
    it "is valid with all required attributes" do
      shower = FactoryGirl.create :shower
      capability = shower.capabilities.create(capability: :mobile_supports_pusher)
      expect(capability).to be_valid
    end
  end
  </code></pre>
  
  <p>But no matter what value I put in for <code>capability</code>, it's always <code>nil</code> and I'm not sure if it's because I'm doing it wrong or this is a limitation.</p>
  
  <p>For example if I do <code>c = Capability.create!(capability: 0)</code> in the console, it saves correctly.</p>
  
  <p>Is it possible to have an association like this? Basically we want a <code>Shower</code> to have any number of <code>Capabilities</code> but only one of each for the enum, if that makes sense.</p>