John Kopanas
2006-Nov-01 00:10 UTC
What To Do When You Have A Relationship Between Two Objects Of The Same Type
Lets say user1 is friends with user2 where user one is a relationship table. How do you connect two users on the same id i.e. user_id? user_id -> friends with -> user_id friends table user_id | user_id | description | created_at | updated_at We can''t have two user_id''s so any suggestions how can I do this? Thanks for your help! :-) -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org http://www.kopanas.com http://www.cusec.net http://www.soen.info --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Francois Beausoleil
2006-Nov-01 00:18 UTC
Re: What To Do When You Have A Relationship Between Two Objects Of The Same Type
Hello John, 2006/10/31, John Kopanas <kopanas@gmail.com>:> We can't have two user_id's so any suggestions how can I do this?Nothing prevents you from naming one of the foreign key "friend_id", right ? And from there, belongs_to / has_many have a :foreign_key option which tell it the name of the foreign key. Hope that helps ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---