你好,我在routes.rb
中有这个 namespace :admin do
root :to => "admin#index"
resources :employees
resources :customers
resources :users
end
前端正常工作,我可以登录管理,但我有像
这样的链接 <li><%= link_to "users", admin_users_path %></li>
等。
如果我点击该链接,我会收到此错误
uninitialized constant Admin::UsersController
或者如果我点击admin_employees_path我得到
uninitialized constant Admin::EmployeesController
并且该行为发生在管理中的每个环节
在服务器上rails s
一切正常:p
用户控制器就像那样定义
class UsersController < Admin::AdminController
文件位置 控制器/管理/ admin_controller.rb 控制器/ users_controller.rb
我的环境文件
development.rb
Web::Application.configure do
config.cache_classes = false
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.action_dispatch.best_standards_support = :builtin
config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.assets.compress = false
config.assets.debug = true
end
production.rb
Web::Application.configure do
config.cache_classes = true # different
config.assets.compress = true # different
config.consider_all_requests_local = true # temporary true
config.action_controller.perform_caching = false
# not in development
config.serve_static_assets = false
config.assets.compile = true
config.assets.digest = true
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
end
答案 0 :(得分:0)
您正在管理命名空间下定义用户资源,但未在控制器中定义它。
将users_controller移动到/ controllers / admin / users_controller并将命名空间附加到该类声明
class Admin::UsersController < Admin::AdminController
或者移动你的 resources:admin命名空间之外的用户。