title: Trouble adding many-to-many relationship to Devise Model in Rails
body: <p>I have a number of functioning many-to-many relationships in my app but I'm having trouble adding this new one (<code>user_airports</code> and <code>home_airports</code>)! </p>
  
  <p>I'm trying to give my <code>User</code> a <code>home_airports</code> array, where a <code>User</code> has many <code>home_airports</code> and an <code>Airport</code> has many <code>Users</code> (conceptually an airport "belongs to" many users but technically <code>has_many</code> of course). I created and migrated the join table and added all the relevant macros to the models. Here's the code:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class User &lt; ApplicationRecord
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :validatable
    devise :omniauthable, omniauth_providers: %i[facebook]
  
    has_many :vacations
  
    has_many :user_airports, dependent: :destroy
    has_many :home_airports, through: :user_airports, source: :airport
  end
  
  
  class UserAirport &lt; ApplicationRecord
    belongs_to :user
    belongs_to :airport
  end
  
  
  class Airport &lt; ApplicationRecord
    has_many :deal_origins
    has_many :origin_deals, through: :deal_origins, source: :deal
  
    has_many :deal_destinations
    has_many :destination_deals, through: :deal_destinations, source: :deal
  
    has_many :user_airports
    has_many :users, through: :user_airports
  end
  
  # from my schema.rb
    create_table "user_airports", force: :cascade do |t|
      t.integer "user_id"
      t.integer "airport_id"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
    end
  
  </code></pre>
  
  <p>The <code>vacations</code> relationship in <code>User</code> works fine (just as an example of something that works). </p>
  
  <p>The <code>users</code> relationship in <code>Airports</code> actually works fine too. But its inverse does not: with <code>User</code>, when I call <code>user.user_airports</code> or, more importantly, <code>user.home_airports</code>, I get a <code>NoMethodError</code></p>
  
  <pre><code>user.home_airports &lt;&lt; Airport.first                                                                                               
  NoMethodError: undefined method `home_airports' for #&lt;User:0x00007fa7bfc9f630&gt;
  </code></pre>
  
  <p>I'm showing, above, the <code>deal_origins</code> and <code>deal_destinations</code> relationship in <code>Airport</code> because those are many-to-many relationships that work and that appear to be identically implemented to the <code>User</code> relationships. (I'm not showing my <code>Deal</code> model, but I could if that would be helpful)</p>
  
  <p>The ONLY thing I can imagine is different is that <code>User</code> is a <code>devise</code> model.</p>
  
  <p>What's going wrong here?</p>
  
  <p>EDIT: 
  In response to suggestions in the comments, I stopped my server, exited the console, restarted the server, restarted the console. Still getting the same problem:</p>
  
  <pre><code>user.user_airports                                                                                                                
  NoMethodError: undefined method `user_airports' for #&lt;User:0x00007fa7bc430e70&gt;
  from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.3.7/gems/activemodel-5.2.2/lib/active_model/attribute_methods.rb:430:in `method_missing'
  user.home_airports                                                                                                                
  NoMethodError: undefined method `home_airports' for #&lt;User:0x00007fa7bc430e70&gt;
  from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.3.7/gems/activemodel-5.2.2/lib/active_model/attribute_methods.rb:430:in `method_missing'
  </code></pre>
  
  <p>Please let me know if there's any other code you'd like to see, and let me know what you need. Thank you!</p>