我对 rails 4 路由有一些问题。目前路由是这样的。
analytic_practiceday_path POST /analytics/:analytic_id/practiceday(.:format) analytics#practiceday
analytic_practiceuser_path GET /analytics/:analytic_id/practiceuser(.:format) analytics#practiceuser
我想:analytic_id
删除部分。所以它看起来像这样
analytic_practiceday_path POST /analytics/practiceday analytics#practiceday
analytic_practiceuser_path GET /analytics/practiceuser analytics#practiceuser
我目前的代码是
resources :analytics, :only =>"index" do
post 'practiceday', to: "analytics#practiceday"
get 'practiceuser', to: "analytics#practiceuser"
end
我知道可以明确声明它,
get '/analytic/practiceday', to: "analytics#practiceday", as: "analytic_practice_day"
但我有 20~30 条路线要定义。如果有人能告诉我更好的方法,我将不胜感激。
谢谢。