问题
All of a sudden my app seems to have developed a routing error uninitialized constant DashboardController
I am running Rails 3.2.0 with ActiveAdmin (0.6.0) and up until today everything seemed to be working fine.
The log is reporting the following error which occuring when trying to run 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)
Has anyone else had this error? Any help people can offer would be much appreciated!
回答1:
Move the root :to => yourController#index above the ActiveAdmin.routes(self)
When you run bundle exec rake routes
you will see yourController#index above dashboard#index.
That problem occurs because It has 2 routes to root (1 from your and 1 from Active Admin)
回答2:
I was missing file app/admin/dashboards.rb , see https://github.com/gregbell/active_admin#upgrading and https://raw.github.com/gregbell/active_admin/master/lib/generators/active_admin/install/templates/dashboard.rb
来源:https://stackoverflow.com/questions/15818446/active-admin-ruby-on-rails-dashboard-controller-error