0

在我的 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 和 rake 路由的结果

https://gist.github.com/3074287

谢谢,拉斯

4

1 回答 1

1

这可能是因为 id 为 nil

于 2012-07-09T06:49:31.917 回答