title: Associations Setup Correctly Results in a Uninitialized Constant
body: <p>I have a simple <code>many_to_many</code> relationship between <code>User</code> and <code>Stake</code> through <code>UserStake</code>, everything seems to be setup correctly but results in a <code>NameError (uninitialized constant User::Stakes)</code>:</p>
  <pre class="lang-rb prettyprint-override"><code>#db/schema.rb
  ActiveRecord::Schema.define(version: 2020_12_19_070749) do
  
    create_table &quot;stakes&quot;, force: :cascade do |t|
      t.string &quot;address&quot;
      t.datetime &quot;created_at&quot;, precision: 6, null: false
      t.datetime &quot;updated_at&quot;, precision: 6, null: false
    end
  
    create_table &quot;user_stakes&quot;, force: :cascade do |t|
      t.integer &quot;user_id&quot;
      t.integer &quot;stake_id&quot;
      t.datetime &quot;created_at&quot;, precision: 6, null: false
      t.datetime &quot;updated_at&quot;, precision: 6, null: false
    end
  
    create_table &quot;users&quot;, force: :cascade do |t|
      t.string &quot;username&quot;
      t.datetime &quot;created_at&quot;, precision: 6, null: false
      t.datetime &quot;updated_at&quot;, precision: 6, null: false
      t.string &quot;password_digest&quot;
    end
  
  end
  </code></pre>
  <pre class="lang-rb prettyprint-override"><code>#app/models/stake.rb
  class Stake &lt; ApplicationRecord
      has_many :active_stakes
      has_many :user_stakes
      has_many :users, through: :user_stakes
  end
  
  #app/models/user.rb
  class User &lt; ApplicationRecord
      has_many :user_stakes
      has_many :stakes, through: :user_stakes
      
      has_secure_password
  end
  
  #app/models/user_stake.rb
  class UserStake &lt; ApplicationRecord
      belongs_to :users
      belongs_to :stakes
  end
  </code></pre>
  <p>When I try the association through <code>rails c</code> the following error <code>NameError (uninitialized constant User::Stakes)</code> appears:</p>
  <pre class="lang-rb prettyprint-override"><code>2.6.3 :019 &gt; s
   =&gt; #&lt;Stake id: 310524, address: &quot;stake1u8003gtvhcunzzmy85nfnk6kafd8lks2mykfzf0n4hq4...&quot;, created_at: &quot;2020-12-08 12:08:25&quot;, updated_at: &quot;2020-12-08 12:08:25&quot;&gt; 
  2.6.3 :020 &gt; u
   =&gt; #&lt;User id: 21, username: &quot;s324xexd&quot;, created_at: &quot;2020-12-19 00:16:31&quot;, updated_at: &quot;2020-12-19 00:16:31&quot;, password_digest: [FILTERED]&gt; 
  2.6.3 :021 &gt; u.stakes &lt;&lt; s
  Traceback (most recent call last):
          1: from (irb):21
  NameError (uninitialized constant User::Stakes)
  2.6.3 :022 &gt; u.stakes
  Traceback (most recent call last):
          2: from (irb):22
          1: from (irb):22:in `rescue in irb_binding'
  NameError (uninitialized constant User::Stakes)
  </code></pre>