raw1z / amistad

Adds friendships management into a rails application
http://github.com/raw1z/amistad
MIT License
185 stars 71 forks source link

Adding friend_with method to the friendship model plus tests #17

Closed ordermuppet closed 11 years ago

ordermuppet commented 13 years ago

I've been using this gem and finding it really easy to work with. The only thing I've been wishing for is a way to find a user given a friendship and the other friend involved in the friendship.

My particular use case is a Rails application that uses RESTful routes such as "/friendships/3" (where 3 is the ID of the friendship) - on the controller side, I know the friendship (from the id param), I know one user in the friendship (from the logged in current_user), but I don't know the other user, and I need to retrieve it so I can block/unblock/approve/whatever.

I've added a simple friend_with method to the friendship model that will, given one half of the friendship, return the other half. Let me know if there's an easier/cleaner way to accomplish what I'm trying to do that I've overlooked.