在routes.rb
,
resources :projects
给出以下路线
/projects/
/projects/:id
在使用嵌套资源时
resources :projects do
resources :photos
end
它给出了以下路线
/projects/
/projects/:id
/projects/:project_id/photos
/projects/:project_id/photos/:id
这给了我一个问题,因为我必须编写特定于控制器的 before_filter 在params[:id]
和params[:project_id]
for之间进行选择Project.find(params[:project_id] || param[:id])
有什么办法可以改变:project_id
所有路线的路线吗?
/projects/
**/projects/:project_id**
/projects/:project_id/photos
/projects/:project_id/photos/:id