Topic: RESTful friends system
I used to have actions like add_friend, remove_friend, and show_friends on my users controller but I'm trying to redo it in a RESTful way, so I'm just wondering how the database and new model/controller should be set up.
My old database had a table called friends_users that had user_id and friend_id columns. In the RESTful way I'm thinking of naming the relationship between users "friendships" and then having a new model/controller for that. Should I now have a table called friendships with id, user_id and friend_id columns? Or should I just leave the table as is? It seems like friendships need their own id to be able to have routes like /friendships/1. That route looks weird to me though, because its identifying the friendship instead of the user(s).
Also, how would you show all the friends for a particular user? With /friendships/index? Shouldn't there be a unique url for each user's friends page (like /users/1/friends)?
Should it even be called "friendships"? That seems weird to me too, but when DHH was explaining users and groups, he named the relationship "membership" to turn it into a RESTful design.