在我的路线我有一个嵌套的资源,像这样:Rails的路线 - 嵌套单一的资源用:ID,而不是:资源名_ID
namespace :public, path: "/" do
constraints(Subdomain::Public) do
namespace :v1 do
post "/webhooks/:id/test", to: "webhooks#test"
resources :webhooks, only: [ :index, :show, :create, :update, :destroy ]
的后网络挂接路线变为:
POST /v1/webhooks/:id/test(.:format)
这很好。不过,我想打扫一下有点像这样:
namespace :public, path: "/" do
constraints(Subdomain::Public) do
namespace :v1 do
resources :webhooks, only: [ :index, :show, :create, :update, :destroy ] do
post :test
end
这导致这样的路线:
POST /v1/webhooks/:webhook_id/test(.:format)
不好。我想在路径中使用常规:id。我在这里做错了什么?
这就是我一直在寻找的。 – cheeseandpepper 2014-08-28 16:17:52