In routes.rb
,
resources :projects
gives the following routes
/projects/
/projects/:id
While using nested resources like
resources :projects do
resources :photos
end
it gives the following routes
/projects/
/projects/:id
/projects/:project_id/photos
/projects/:project_id/photos/:id
This gives me the problem because I have to write controller specific before_filter choosing between params[:id]
and params[:project_id]
for doing Project.find(params[:project_id] || param[:id])
Is there any way to change the routes to have :project_id
itself for all routes?
/projects/
**/projects/:project_id**
/projects/:project_id/photos
/projects/:project_id/photos/:id