rails 4控制器命名空间

时间:2013-07-12 13:48:48

标签: ruby-on-rails-4 nested-routes

route ->
 namespace :admin do
   get '' => 'home#index'
 end


 class Admin::ApplicationController < ActionController::Base
 layout 'admin'

 class Admin::HomeController < Admin::ApplicationController

当我第一次打开/时,然后打开/ admin / rails告诉我这个:

 home_controller.rb:1: warning: toplevel constant ApplicationController referenced by     Admin::ApplicationController

但是,当我第一次到/ admin /所有工作时,我的预期如何。

问题出在哪里,以及如何解决?

1 个答案:

答案 0 :(得分:0)

试试这个:

module Admin
  class ApplicationController <  ::ApplicationController
  end
end

module Admin
  class HomeController < ApplicationController
  end
end