# Multiple Many-to-Many relationship on same both modles?

**URL:** <https://www.ruby-forum.com/t/multiple-many-to-many-relationship-on-same-both-modles/110793>\
**Category:** Rails\
**Created:** [July 31, 2007, 12:45am UTC](https://www.ruby-forum.com/t/multiple-many-to-many-relationship-on-same-both-modles/110793 "2007-07-31T00:45:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mister\_Yu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@Mister\_Yu](https://www.ruby-forum.com/u/Mister_Yu)\
**Post date:** [July 31, 2007, 12:45am UTC](https://www.ruby-forum.com/t/multiple-many-to-many-relationship-on-same-both-modles/110793/1 "2007-07-31T00:45:10Z")

</div>

Hi i am still very new to ROR, i hope you can help me with this  
problem.

i have two modles, Place and User

users plant to go to places  
users have been to places  
users live in the places

these are 3 relationships. how do i write “has\_many” statement to make  
ROR take care them for me?

or i have to write my own codes for them?

thanks.

---

<div class="post-metadata">

**Author:** ![Mister\_Yu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@Mister\_Yu](https://www.ruby-forum.com/u/Mister_Yu)\
**Post date:** [July 31, 2007, 4:47am UTC](https://www.ruby-forum.com/t/multiple-many-to-many-relationship-on-same-both-modles/110793/2 "2007-07-31T04:47:25Z")

</div>

i’m still new too, but i think one way is to make join models  
representing each relationship:

e.g.

make a migration:  
def self.up  
create\_table :planned\_places do |t|  
t.column :place\_id, :integer  
t.column :user\_id, :integer  
end  
create\_table :visited\_places do |t|  
t.column :place\_id, :integer  
t.column :user\_id, :integer  
end  
create\_table :lived\_places do |t|  
t.column :place\_id, :integer  
t.column :user\_id, :integer  
end  
end

then in your model;  
has\_many :planned\_places  
has\_many :visited\_places  
has\_many :lived\_places
