load_missing_constant Expected foo.rb to define Foo
May 5th, 2008
Hello sobering Monday.
Eager to jump back into the fray of a suite of specs I left half baked Friday, I spent a little time first trying to figure out why I was getting a particular error when attempting to run the spec suite.
1 2 3 |
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:249: in `load_missing_constant': Expected /sekrat/awesomeproject/app/models/awesome.rb to define Awesome (LoadError) |
Nice, eh? I’ve seen it before but I can never remember what causes it. Actually, I there are probably a number of ways you might run into this error message, such as the load order for plugins being incorrect. The way I encountered it today was by injecting a typo into an AR method, set_inheritance_column lacking the final ‘n’ in this case. So if you are shedding some tears over this, double check the spelling on your AR methods (has_many, belongs_to, etc..)
September 16th, 2008 at 02:52 AM
Hey I had the same problem. It turned out that I had a typo too. My model was named plural instead of singular which took me 30 minutes to figure untill I read your post. So sometimes documentions do not help as much as experience does. :)
February 10th, 2009 at 06:09 PM
Ran into this today on an app that I was moving from one server from another. I found that the best way to diagnose is to fire up script/console, which gives a much more helpful stack trace—in my case, I was missing the acts_as_state_machine plugin.
February 3rd, 2010 at 01:46 PM
Well, in my case, after beating my head against the error for a while I figured out that I was naming my controller ‘FOO’, and if I named it ‘foo’ the Webrick server would start. Apparently the parser is treating my controller as a constant because I used upper case in the name script/generate controller ‘FOO’.
Hope this helps.
TM