An Error Caused By Not Missing a Constant

by Brian on 12/22/2008

Usually, when programming you get an error that you are missing a variable, or something, but in Rails, sometimes you get errors like this:

ArgumentError (Object is not missing constant WhateverController!)

There’s been a few other occasions where I have gotten errors that made absolutely no sense. I think they are caused by the “magic” that Rails does in the background to make a lot if its conventions work.

I Googled this error and learned that it is sometimes caused by calling the initializer of a class that does not have one, such as calling .new on a notifier. However, that was not the cause of my error. I had a namespace defined in my routes.rb file, however, the controllers in that namespace were not in the proper directories, they were just in the root app/controllers, directory, rather than app/controllers/namespace/whatever_controller.rb. I think in most cases Rails is smart enough to figure out that your controller is in app/controllers, but I just happened to be deploying my app inside of mod_rails (phusion).

Phusion must be playing around with the magic.

Related posts:

  1. Filter Sensitive Data From Your Logs
  2. NoMachine Mac OS X 10.6.3 bug
  3. Generating Schema from Existing Database
  4. The problem with dynamically typed languages
  5. Sudoku Results
blog comments powered by Disqus

Previous post:

Next post: