views:

288

answers:

1

In a Rails3 Application I keep getting

..gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:459:in 'load_missing_constant': uninitialized constant ApplicationController (NameError)

Even though app/controllers/application_controller.rb exists and is valid. What is the problem

A: 

There are probably several causes of this, but the one that got me was having a config.ru file in my home directory:

Rails3 attempts to figure out where your application's root directory is. The logic for this is begin looking in the directory ../railties/lib/rails/application, and then walking up the path looking for a directory with config.ru and assuming that is the app root - if none is found then the current working directory is the app root.

If your Gems are installed in a subdirectory of your home dir (RVM, Local Gems and Bundler do this) then at one point this will check for the existence of config.ru in your home dir. If this exists it will try to load the application from your home dir.

The solution is to not have config.ru in your home dir

Laurie Young
Another solution would be to have a valid config.ru file that booted your Rails application in the application's root.
Olly