# Has\_many :through question

**URL:** <https://www.ruby-forum.com/t/has-many-through-question/193520>\
**Category:** Rails\
**Created:** [August 19, 2010, 4:48am UTC](https://www.ruby-forum.com/t/has-many-through-question/193520 "2010-08-19T04:48:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [August 19, 2010, 4:48am UTC](https://www.ruby-forum.com/t/has-many-through-question/193520/1 "2010-08-19T04:48:54Z")

</div>

I am trying to create an association table using the “:through” option  
in “has\_many” but not having success. I have created the necessary  
migrations of the association tables and run rake db:migrate

I have the following model:

class Group \< ActiveRecord::Base  
has\_many :users, :through =\> :group\_user  
has\_many :invites, :through =\> :group\_invite, :class\_name =\> “User”  
belongs\_to :owner, :class\_name =\> “User”  
end

class GroupUser \< ActiveRecord::Base  
belongs\_to :group  
belongs\_to :user  
end

Loading development environment (Rails 2.3.8)

> > g = Group.find(1)  
> > =\> #\<Group id: 1, name: “My Group”, owner\_id: 1, created\_at: “2010-08-19  
> > 02:30:10”, updated\_at: "  
> > 2010-08-19 02:30:10"\>
> 
> > g.users \<\< User.find(2)  
> > ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the  
> > association :group\_user   
> > in model Group  
> > from  
> > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active\_record/reflection.rb  
> > :348:in `check_validity!' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations/\ association_proxy.rb:56:in`initialize’  
> > from  
> > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active\_record/associations/  
> > association\_collection.rb:20:in `initialize' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/associations.\ rb:1306:in`new’  
> > from  
> > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active\_record/associations.  
> > rb:1306:in `users’  
> > from (irb):2

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [August 19, 2010, 5:14am UTC](https://www.ruby-forum.com/t/has-many-through-question/193520/2 "2010-08-19T05:14:35Z")

</div>

Disregard, solution found.
