Here is a design related question to those out there that are using
restful routing with rails. What I'm trying to figure out a good way
to design my URLs for creating objects on the join table.
For example, take the classic example of friendships. Say a user has
many friends, through friendships. A user also has many fans, through
friendships, by switching the :source flag. How would you create that
Assume I have friends and fans as a nested resource of users for this
example. I have access to self.current_user, so I can easily check to
make sure one is posting to his own resource.
1. Define the URL with a query parameter
2. Keep the URL clean, by posting to the friends fans controller
3. Edit the route to add a friend_id to the create method in the
There are plenty of more ways to do this, and all of them are easy to
do. What do most people use? I haven't found too many topics out
there about how people are creating the join resource. Is it common
to do things like POST to one resource and DELETE from another? Or,
to POST to a resource but add a query param to the path to get all the
Thanks for any tips or references you wish to share.