从嵌套资源中删除命名空间

Remove namespace from nested resource

我有一个 namspaced 资源,但我想要一个特定的嵌套资源路由到 non-namespaced 控制器,例如:

namespace :admin do
  resources :posts do # /admin/posts => Admin::PostsController
    resources :audits, only: [:index] # /admin/posts/1/audits => AuditsController
  end
end

guides state that:

If you need to use a different controller namespace inside a namespace block you can specify an absolute controller path, e.g: get '/foo' => '/foo#index'.

但这会导致 "wrong constant name",因为 rails 试图将 admin//audits 转换为常量。

我最后只是把它完全分开然后做

get 'admin/users/:user_id/audits', to: 'audits#index'

还是不太理解导游的引述,我想肯定是不正确的。