views:

49

answers:

2

I want a "friend" relationship, as in "social site friends", which means: if I'm friending you you invariably friend me. If I remove you from friends, you do that, too. (well, you get the idea).

Currently this is done with duplicate relations and an observer to add/remove the second (more correctly, "other") relation when the first gets created/deleted.

What's the convenient way to implement the subject without duplicating records in the relation table? Maybe there's a gem/plugin to do this?

+1  A: 

Leonid, search is your friend, in other words, "vpoezg" :)

Here is one of the many topics on the subject: http://stackoverflow.com/questions/1034411/how-do-i-do-reflexive-self-join-relationships-in-activerecord/1035087

neutrino
True. Question closed.
Leonid Shevtsov
A: 

Fortunately there is a Railscast on this very topic! Or if you prefer, you can read the instructions as an ASCIIcast.

John Topley