uninitialized constant ApplicationController (Name

2019-07-29 11:11发布

问题:

I've set up a simple application online on a rackspace cloud server but I'm getting the following error message from phusion passenger:

uninitialized constant ApplicationController (NameError)
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:in `block in constantize'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in `each'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in `constantize'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/devise-2.2.4/app/controllers/devise_controller.rb:2:in `<top (required)>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/devise-2.2.4/app/controllers/devise/confirmations_controller.rb:1:in `<top (required)>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:438:in `block in eager_load!'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:436:in `each'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:436:in `eager_load!'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `each'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `all'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/engine.rb:434:in `eager_load!'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /var/www/ideamobb.com/config/environment.rb:5:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:82:in `eval'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:82:in `preload_app'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:127:in `<module:App>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
  /var/www/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.8/helper-scripts/rack-preloader.rb:5:in `<main>'

I'm not sure whats going on here - the application works perfectly fine on my localhost - all the gems are installed, migrations are cleared - so what exactly might be the problem here?

回答1:

I think you are missing ApplicationController. All other controllers inherit from this class

A simple application_controller.rb

class ApplicationController < ActionController::Base

end


回答2:

In my case I misspelled "application" in my routes file. Make sure to check your spelling!