Rails app not finding models

Hi everyone!

I’ve been trying to get my rails app to work on Dreamhost. I followed the below steps and it sort of works. The one controller I have that doesn’t have a corresponding model works. Whenever I try using one that requires a model, I get a rails application error. Below are the steps I took:

  1. Uploaded local rails app to ~/.

  2. Made sure production database settings are correct in railsapp/config/database.yml.

  3. Modified all instances of dispatch.cgi in the railsapp/public/.htaccess file to dispatch.fcgi. To my knowledge, there is only one line you need to change that looks like this:

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

  1. Modified the shebang location (#!) of ruby in the railsapp/public/dispatch.fcgi file to #!/usr/bin/ruby from whatever it was.

  2. Switched to the production environment by uncommenting line 5 in railsapp/config/environment.rb.

  3. Created a symlink to my site directory:

$ cd ~/railsapp
$ ln -s public ~/yoursite.com/railsapp

I also tried creating a subdomain and putting my app in the root directory. Same deal. I know the app is accessing the database correctly and it works perfectly on my local machine using script/server. Any ideas? Did I configure something wrong somewhere? Thanks!


Since the controller without the model works, it sure sounds like you aren’t able to access the database. I’d copy your database settings to both development and production in your database.yml. Also, be sure that you are using the correct host setting (not localhost).

You can try the short script here:


to make sure. It will spit out more info if it fails and that may help with your debugging.


-Tom Wilcoxen
convergent arts

This is definitely not the problem. At one point, it was displaying database info in the aforementioned controller. I also grabbed that script you pointed me to and ran it. No problem pulling database info. Then I double (and triple) checked the database settings and they’re correct…


Try this real quick. From your rails_root, fire up the console:

ruby script/consoleFrom the command you get you can create one of your domain objects, for example, Person:

bob = Person.new bob.save This will actually be running within your rails environment. If you have any validations on the model you’ll have to satisfy them. It’s pretty useful in general. See what you get.


-Tom Wilcoxen
convergent arts

I had tried that earlier. Here’s what I get:

Loading development environment.


MissingSourceFile: no such file to load – MD5
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:in require__' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:214:in require' from script/../config/../config/../app/models/user.rb:1 from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:207:inload’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:207:in load' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:39:inrequire_or_load’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:22:in depend_on' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:178:inrequire_dependency’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:178:in require_dependency' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:194:inconst_missing’
from (irb):1

It looks like you’re using some sort of login system that uses MD5 and it can’t find that file. Probably there’s a reference to it in your Users model. It may be 'require’d in the Users model, but it can’t find the source file. There should probably be a file under your /lib directory that defines MD5. (I say probably because it could also be in /vendor somewhere, but the old-school (e.g. last summer) place was in /lib.)

Can you try a model object that is simpler? Just a table and a bare minimum model class to remove any other issues. It looks like it’s found your model and probably it’s connecting to the database ok.

-Tom Wilcoxen
convergent arts

I’m just using the md5.rb library that’s part of the standard library to hash the password… I don’t see why I should have to include it in the rails app anywhere. I’ll give your suggestion a shot though and see what happens.

Well, well, well. That appears to have fixed the problem. I commented out all references to the MD5 library and it just started working. What the crap? That library isn’t a gem and I know I didn’t manually install it… Why can’t rails find it then?

I figured it out. I was requiring ‘MD5’. The filename is ‘md5.rb’ and Dreamhost servers are case-sensitive. So, once I switched the require to ‘md5’ everything was peachy.

Thanks for all the help!