Bidirectional relationships in ActiveRecord [duplicate]
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, y开发者_如何学编程ou 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?
Fortunately there is a Railscast on this very topic! Or if you prefer, you can read the instructions as an ASCIIcast.
精彩评论