在我的routes.rb中有
resources :clients_assessments do
member do
get :medical_edit
get :mental_health_edit
get :personal_edit
end
collection do
end
end
提供路线
medical_edit_clients_assessment GET /clients_assessments/:id/medical_edit(.:format) {:action=>"medical_edit", :controller=>"clients_assessments"}
mental_health_edit_clients_assessment GET /clients_assessments/:id/mental_health_edit(.:format) {:action=>"mental_health_edit", :controller=>"clients_assessments"}
personal_edit_clients_assessment GET /clients_assessments/:id/personal_edit(.:format) {:action=>"personal_edit", :controller=>"clients_assessments"}
clients_assessments GET /clients_assessments(.:format) {:action=>"index", :controller=>"clients_assessments"}
POST /clients_assessments(.:format) {:action=>"create", :controller=>"clients_assessments"}
new_clients_assessment GET /clients_assessments/new(.:format) {:action=>"new", :controller=>"clients_assessments"}
edit_clients_assessment GET /clients_assessments/:id/edit(.:format) {:action=>"edit", :controller=>"clients_assessments"}
clients_assessment GET /clients_assessments/:id(.:format) {:action=>"show", :controller=>"clients_assessments"}
PUT /clients_assessments/:id(.:format) {:action=>"update", :controller=>"clients_assessments"}
DELETE /clients_assessments/:id(.:format) {:action=>"destroy", :controller=>"clients_assessments"}
当我尝试在辅助文件中使用它们时,如
route = medical_edit_clients_assessment_path(id)
生成错误消息
No route matches {:action=>"medical_edit", :controller=>"clients_assessments"}
我必须将其更改为
route = "/clients_assessment/#{able_id}/medical_edit"
绕过错误消息。虽然有像
这样的路线,但有什么好笑的route = (able_id.nil? ? new_client_path : edit_client_path(able_id))
工作正常。
我知道有人会要求它所以这里是整个routes.rb和佣金路线的结果
https://gist.github.com/3074287
谢谢,Russ
答案 0 :(得分:1)
这可能是因为id为nil