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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jemminger
2007-Jul-31 02:46 UTC
Re: Multiple Many-to-Many relationship on same both modles???
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
On Jul 30, 6:44 pm, Mister Yu
<eryan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---