我有两个控制器模块(它们扩展了一组控制器,因为它们共享大部分代码)。
我的路线文件目前看起来像这样:
constraints(!Subdomain) do
scope :module => "standalone" do
namespace "account" do
resources :questionnaires, :only => :index do
resources :responses, :except => :new do
member do
get 'save'
end
resources :questions, :only => [:index, :show] do
resources :answers, :only => [:index, :show] do
resource :choice, :only => [:create]
end
end
end
end
end
end
end
constraints(Subdomain) do
scope :module => "organise" do
namespace "account" do
resources :questionnaires, :only => :index do
resources :responses, :except => :new do
member do
get 'save'
end
resources :questions, :only => [:index, :show] do
resources :answers, :only => [:index, :show] do
resource :choice, :only => [:create]
end
end
end
end
end
namespace "admin" do
resources :questionnaires, :only => :index do
resources :responses, :only => [:index, :show]
end
end
end
end
这一切看起来很好,除了两组路由似乎仍然被解析而一组将覆盖另一组 - 仅为一组生成路径助手。以下是生成的路由的拆分列表:http://pastie.org/private/nhvmokit7y0dwywqtdlq(它非常大,您可能需要将其放在文本编辑器中以便更轻松地阅读)。
正如您所看到的,它不会为第二组路由生成帮助程序。在导航网站时,它似乎也无法正确识别它们。
以前有没有人经历过这种情况,或者知道某种解决方法?
答案 0 :(得分:0)
与少数人讨论后,我认为解决此问题的最简单方法是使用浅嵌套控制器,并依靠权限来控制用户可以看到的内容。