I have a many-to-many relationship between users and teams (as a has_many :through), and I’m trying to setup a “team members” join model as a resource in the routes.
In my layouts I’ve setup a “team context form” that sets a session variable for the current_team, and I want the route for the team_members resources to be defined as /team_members/:user_id/show. Is there any way to do this with the resources :team_members in routes.rb?
I’ve tried using :path_names => {:action => "\some\url"}, however for actions that require an :id the router appends the route to be something like "\:id\some\url"
edit:
If you want to be able to edit the team membership, you could have
and then, to edit the membership =>
/users/:user_id/team_members/:id/editAnd then you can do whatever you want in the team_members_controller.
Or as numbers1311407 said, just
resources :team_membersand you’ll have all the rest routes to work with the team memberships.Really don’t want the standard
/teams/:team_id/users/:id?If you really want
/team_members/:user_id/showYou could just do
But I dont think it’s a good idea.