title: has_many :through uninitialized constant
body: <p>I've read the documentations and tons of tutorials about the has_many :through relations in Rails but I can't for the life of me get the hang of it.</p>
  
  <p>I'm trying to add a group to my current_user(devise) and I have a table in between <code>Group</code> and <code>User</code> with a status(The user's status is changeable for that group).</p>
  
  <p>Whenever I create a new Group now I get an error saying <code>uninitialized constant Group::GroupUser</code></p>
  
  <p>here are my models:</p>
  
  <p><strong>groupuser.rb</strong></p>
  
  <pre><code>class GroupUser &lt; ActiveRecord::Base
      belongs_to              :group
      belongs_to              :user
  end
  </code></pre>
  
  <p><strong>group.rb</strong></p>
  
  <pre><code>class Group &lt; ActiveRecord::Base
      has_many                            :clients
      has_and_belongs_to_many             :pictograms
  
      has_many :group_users
      has_many :users, :through =&gt; :group_users
  
      accepts_nested_attributes_for :clients
  
      validates_length_of                 :name,  :minimum =&gt; 5
      validates_presence_of               :name
      validates_presence_of               :background
      validates_presence_of               :clocktype
  end
  </code></pre>
  
  <p><strong>User.rb</strong></p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :token_authenticatable, :confirmable,
    # :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
  
  
    validates_presence_of   :first_name
    validates_presence_of   :last_name
    validates               :email, presence: true, uniqueness: true
  
    has_many :group_users
    has_many :groups, :through =&gt; :group_users
  
    has_attached_file :avatar, :styles =&gt; { 
                                  :medium =&gt; "300x300#", 
                                  :thumb =&gt; "100x100#" 
                               }
    validates_attachment_content_type :avatar, :content_type =&gt; ['image/jpg', 'image/png', 'image/jpeg']
  
    validates_attachment :avatar,
                    :size =&gt; { :in =&gt; 0..1.megabytes }
  
    def completeName
      "#{self.first_name} #{self.last_name}"
    end
  end
  </code></pre>
  
  <p>And the related stuff from <strong>schema.rb</strong></p>
  
  <pre><code>  create_table "group_users", id: false, force: true do |t|
      t.integer "group_id"
      t.integer "user_id"
      t.integer "status",   default: 0
    end
  
    add_index "group_users", ["group_id"], name: "index_group_users_on_group_id"
    add_index "group_users", ["user_id"], name: "index_group_users_on_user_id"
  
    create_table "groups", force: true do |t|
      t.string   "name"
      t.integer  "clocktype"
      t.string   "background"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
    create_table "users", force: true do |t|
      t.string   "first_name"
      t.string   "last_name"
      t.string   "password"
      t.string   "avatar_file_name"
      t.string   "avatar_content_type"
      t.integer  "avatar_file_size"
      t.datetime "avatar_updated_at"
      t.datetime "created_at"
      t.datetime "updated_at"
      t.string   "email",                  default: "", null: false
      t.string   "encrypted_password",     default: "", null: false
      t.string   "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "remember_created_at"
      t.integer  "sign_in_count",          default: 0
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string   "current_sign_in_ip"
      t.string   "last_sign_in_ip"
    end
  
    add_index "users", ["email"], name: "index_users_on_email", unique: true
    add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  </code></pre>
  
  <p>And lastly. <strong>the line that throws the error</strong></p>
  
  <pre><code>@group.users &lt;&lt; current_user
  </code></pre>