One of those Non-descriptive Errors

This one stumped me for a while today. I had an application to deploy which worked fine in development. Deploying to production led to this error:

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.5/lib/activesupport/dependencies.rb:249:in `loadmissingconstant’: Expected /myapp/releases/20090617160914/app/models/widget.rb to define Widget (LoadError)

Googling that error turned up lots of pages for Rails 1.2.x and issues with underscores in names. None of it applied. Widget was definitely being defined in widget.rb. Following the stack trace it appeared that the error was thrown in the Ultrasphinx plugin. After trying a lot of other things, I decided to comment out the Ultrasphinx code in the model and retry. The error changed to this, which was helpful:

Errno::EACCES: Permission denied - /myapp/releases/20090617160914/public/widget/myfile

This model was also using the file
column plugin, and the underlying error was just a permissions problem in the file attachment target directory. I fixed the permissions and put the Ultrasphinx code back in the model, and all was happy. If only that permissions error had shown up first!