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. :)