19

突然间,我的应用似乎出现了路由错误uninitialized constant DashboardController

我正在使用 ActiveAdmin (0.6.0) 运行 Rails 3.2.0,直到今天一切似乎都运行良好。

日志报告尝试运行 localhost:3000 时发生的以下错误:

Started GET "/" for 127.0.0.1 at 2013-04-04 18:59:21 +0100

ActionController::RoutingError (uninitialized constant DashboardController):
  activesupport (3.2.0) lib/active_support/inflector/methods.rb:226:in `block in constantize'
  activesupport (3.2.0) lib/active_support/inflector/methods.rb:225:in `each'
  activesupport (3.2.0) lib/active_support/inflector/methods.rb:225:in `constantize'
  actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:62:in `controller_reference'
  actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:47:in `controller'
  actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:26:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.1) lib/warden/manager.rb:34:in `catch'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/cookies.rb:338:in `call'
  activerecord (3.2.0) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `_run__972453933__call__19086187__callbacks'
  activesupport (3.2.0) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.0) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.0) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.0) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.0) lib/action_dispatch/middleware/static.rb:53:in `call'
  railties (3.2.0) lib/rails/engine.rb:479:in `call'
  railties (3.2.0) lib/rails/application.rb:220:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.0) lib/rails/rack/log_tailer.rb:14:in `call'
  thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.1) lib/thin/connection.rb:79:in `catch'
  thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.1) lib/thin/connection.rb:54:in `process'
  thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
  eventmachine-1.0.3-x86 (mingw32) lib/eventmachine.rb:187:in `run_machine'
  eventmachine-1.0.3-x86 (mingw32) lib/eventmachine.rb:187:in `run'
  thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.1) lib/thin/server.rb:159:in `start'
  rack (1.4.5) lib/rack/handler/thin.rb:13:in `run'
  rack (1.4.5) lib/rack/server.rb:268:in `start'
  railties (3.2.0) lib/rails/commands/server.rb:70:in `start'
  railties (3.2.0) lib/rails/commands.rb:55:in `block in <top (required)>'
  railties (3.2.0) lib/rails/commands.rb:50:in `tap'
  railties (3.2.0) lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:6:in `require'
  script/rails:6:in `<main>'


  Rendered C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (234.0ms)

有没有其他人有这个错误?人们可以提供的任何帮助将不胜感激!

4

2 回答 2

75

将根 :to => yourController#index 移到 ActiveAdmin.routes(self) 上方

当你运行时,bundle exec rake routes你会在dashboard#index 上方看到你的Controller#index。

出现该问题是因为它有 2 条通往 root 的路由(1 条来自您,1 条来自 Active Admin)

于 2013-04-04T19:54:09.633 回答
1

我缺少文件 app/admin/dashboards.rb ,请参阅https://github.com/gregbell/active_admin#upgradinghttps://raw.github.com/gregbell/active_admin/master/lib/generators/active_admin/install /模板/仪表板.rb

于 2013-07-27T15:20:39.117 回答