0

您好,我在 routes.rb 中有这个

  namespace :admin do
    root :to => "admin#index"
    resources :employees
    resources :customers
    resources :users
  end

前端正常工作,我可以登录到管理,但我有像这样的链接

<li><%= link_to "users", admin_users_path %></li>

ETC..

如果我单击该链接,我会收到此错误

uninitialized constant Admin::UsersController

或者如果我点击 admin_employees_path 我得到

uninitialized constant Admin::EmployeesController

这种行为存在于管理的每一个环节

在服务器上rails s一切都很好:p

用户控制器是这样定义的

class UsersController < Admin::AdminController

文件位置 controllers/admin/admin_controller.rb controllers/users_controller.rb

我的环境文件

发展.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

生产.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
4

1 回答 1

0

您在 admin 命名空间下定义您的用户资源,但没有在控制器中定义它。

将您的 users_controller 移动到 /controllers/admin/users_controller 并将命名空间附加到该类声明

class Admin::UsersController < Admin::AdminController

或者将您的资源 :user 移到管理员命名空间之外。

于 2013-08-31T12:11:45.003 回答