I''m having a problem mapping relations between classes representing different roles. For instance, let''s assume a social network. A user can relate to other users thought a friendship relation. So I would like to have a table names friends that would have user1_id and user2_id and some more attributes. Rails would requires something like a many to many relation with a table users_users with two columns: user_id and user_id. Of course this doesn''t make sense. I know how to hack this but I would like to know what''s "the ruby way" for this, using simple active records relations. Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here''s the best explanation of self-referential associations: http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through Scroll down to the comments and you''ll see how it translates to a "friends" situation On Nov 19, 9:21 am, eddie <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m having a problem mapping relations between classes representing > different roles. > > For instance, let''s assume a social network. A user can relate to other > users thought a friendship relation. So I would like to have a table > names friends that would have user1_id and user2_id and some more > attributes. Rails would requires something like a many to many relation > with a table users_users with two columns: user_id and user_id. Of > course this doesn''t make sense. I know how to hack this but I would like > to know what''s "the ruby way" for this, using simple active records > relations. > > Thanks > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chad wrote:> Here''s the best explanation of self-referential associations: > > http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through > > Scroll down to the comments and you''ll see how it translates to a > "friends" situationThis is perfect. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---