Morten
2006-Jul-05 22:13 UTC
[Rails] Routing error "unitialized constant" after refactoring
Hi. I''ve heavily refactored an application. When I access http://0.0.0.0:3000/ I now get the stack trace at the end of this mail. My routes.rb: ActionController::Routing::Routes.draw do |map| map.connect '''', :controller => ''user/dashboard'', :action => ''boo'' map.connect '':controller/:action/:id'', :controller => ''user/dashboard'', :action => ''boo'' end And app/controllers/user/dashboard_controller.rb: class User::DashboardController < ApplicationController def index render :text => "wtf?!" end end If I access http://0.0.0.0:3000/user/dashboard/ the controller loads correctly. I''m wondering why routing complains on DashboardController rather than User::DashboardController.. This is driving me nuts. Anyone care to guess what could be the cause? Morten NameError uninitialized constant DashboardController RAILS_ROOT: /Users/morten/svn/tagticks/config/.. Application Trace | Framework Trace | Full Trace /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing'' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing'' generated/routing/recognition.rb:4:in `recognize_path'' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:510:in `recognize!'' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/rails.rb:73:in `process'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:551:in `process_client'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:550:in `process_client'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:636:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:636:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:625:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:956:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:955:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/mongrel_rails:127:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/command.rb:199:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/mongrel_rails:235 /opt/local/bin/mongrel_rails:18 /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing'' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing'' generated/routing/recognition.rb:4:in `recognize_path'' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:510:in `recognize!'' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/rails.rb:73:in `process'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:551:in `process_client'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:550:in `process_client'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:636:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:636:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:625:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:956:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:955:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/mongrel_rails:127:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/command.rb:199:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/mongrel_rails:235 /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in `const_missing'' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in `const_missing'' /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in `const_missing'' generated/routing/recognition.rb:4:in `recognize_path'' /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:510:in `recognize!'' /opt/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/rails.rb:73:in `process'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:551:in `process_client'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:550:in `process_client'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:636:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:636:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:625:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:956:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel.rb:955:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/mongrel_rails:127:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/command.rb:199:in `run'' /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/mongrel_rails:235 /opt/local/bin/mongrel_rails:18 This error occured while loading the following files: dashboard_controller.rb
> If I access http://0.0.0.0:3000/user/dashboard/ the controller loads > correctly. I''m wondering why routing complains on DashboardController > rather than User::DashboardController..Is "user" a reserved word in routing? If I change map.connect '''', :controller => ''user/dashboard'', :action => ''boo'' to map.connect '''', :controller => ''foo/dashboard'', :action => ''boo'' And move the controller from controllers/user/ to controllers/foo/ it works. Morten