bramski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-12 21:30 UTC
Association: has_many_reflexive?
So, I''m trying to make the sort of thing where you''d have an intermediate join table which for simplicities sake, stores all the friends for a person... persons_table ---------- id friends_table ---------- person_id_left person_id_right But, what''d be nice would be if it were unimportant from which side the connection were made (i.e. non-directional graph), such that... class Person has_many :friends, :association_id => ["person_id_left","person_id_right] end person.friends => #SQL("select * from persons_table join friends_table on friends_table.person_id_left = #{self.id} or friends_table.person_id_right = #{self.id}") Seems like a pretty common scenario, but my google searches aren''t really turning up much, anybody done this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---