How to model a mutual friendship in Rails
问题 I know this question has been asked before on Stack Overflow, but the answers aren't doing it for me in ways I can explain. My general approach was inspired by this tutorial. What I'm trying to do, is create a really simple model for friending users that creates an equivalent friendship on both ends with a single record. At the db level, I just have a 'friendships' table that just has a user_id, a friend_id, and an is_pending boolean column. In user.rb I've defined the relationship as: has