我在我的应用程序中添加了一个名为“Triage”的控制器,并添加了一个 PUT 路由,如下所示:
resources :triage do
collection do
put :process_multiple
end
end
而不是预期的 process_multiple_triage_path 路线,它似乎被处理为process_multiple_triage_index_path
:
process_multiple_triage_index_path PUT /triage/process_multiple(.:format) triage#process_multiple
triage_index_path GET /triage(.:format) triage#index
POST /triage(.:format) triage#create
答:原来是因为分类被 Rails 视为单一资源,因此按照惯例,您需要请求资源的“索引”。