在我的 routes.rb 中:
resources :posts do
get "test"
end
这会产生通常的 RESTful 路由
/post/:id/...
.但是,我也得到了 /post/:post_id/test
.现在我的问题是有时参数被命名为:id,有时是:post_id。我怎样才能使它统一?
谢谢!
最佳答案
指定 :on => :member,否则它充当嵌套资源。
resources :posts do
get 'test', :on => :member
end
关于ruby-on-rails - Rails 路由 - :resource_id vs :id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6479370/