对于这条路线:
resources :projects do
member do
resources :stakeholders
end
end
生成的路线是:
projects_stakeholders GET /projects/projects/:id/stakeholders(.:format) {:action=>"index", :controller=>"projects/stakeholders"}
POST /projects/projects/:id/stakeholders(.:format) {:action=>"create", :controller=>"projects/stakeholders"}
new_projects_stakeholder GET /projects/projects/:id/stakeholders/new(.:format) {:action=>"new", :controller=>"projects/stakeholders"}
edit_projects_stakeholder GET /projects/projects/:id/stakeholders/:id/edit(.:format) {:action=>"edit", :controller=>"projects/stakeholders"}
projects_stakeholder GET /projects/projects/:id/stakeholders/:id(.:format) {:action=>"show", :controller=>"projects/stakeholders"}
由于这些路线有两次a:id参数,如果我有,例如URL'projects / 4 / interests / 11'
在我的日志文件中,我看到了:
Parameters: {"id"=>"11"}
如何从控制器内部访问我的project_id?
感谢!!!
答案 0 :(得分:1)
你周围不需要member do
块。就这样做,你应该开始在你的参数中看到project_id
:
resources :projects do
resources :stakeholders
end