Is members a nested resource? If so define it as one, and understand that this is why you have :project_id
in the route, because :id
in a nested resource is used by the final child item - you can't have multiple nested resources all using the same variable to define their id.
resources :projects do
resources :members
end
Add in a third level of nesting and it becomes a bit clearer to explain:
resources :projects do
resources :members do
resources :colours
end
end
With this nesting you could visit app/projects/:project_id/members/:member_id/colours/:id
which would be served by the colours
controller, which knows that :id
defines an instance of that controllers model, and any other named id's belong to other resources.
Otherwise I think you just need to define it as a member method:
resources :projects do
member do
get 'members'
end
end
This tells the route that the action members
is a non-resource action belonging to an instance of project
, which I think should sort you out, but be sure it's the right thing to do.
See section 2.10 of Rails Routing from the Outside In