我想创建以下路线:
Prefix Verb URI Pattern Controller#Action
configuration GET /configuration configurations#index
configuration_team GET /configuration/teams/:id configurations/teams#show
但是拥有单数“配置”URI 和复数“configurations#index”控制器命名空间似乎不合常规。
到目前为止我所得到的是:
get '/configuration', to: 'configurations#index', as: :configuraiton
namespace :configuration { ... }
遗憾的是,这为控制器创建了一个单一的
configuration/
命名空间。
有方便的方法吗?或者我应该坚持约定(如果我是对的,
/configurations
URI 和命名空间)
这可能不是最好的解决方案,但我最终得到了:
get '/configuration', to: 'configuraitons#index', as: :configuration
scope :configuration do
resources :teams, only: %i[show], controller: 'configurations/teams', as: :configuration_team
end
创建以下路线:
Prefix Verb URI Pattern Controller#Action
configuration GET /configuration configurations#index
configuration_team GET /configuration/teams/:id configurations/teams#show