Hostmonster on Rails

A client of mine recently moved their web hosting to Hostmonster, and I was tasked with migrating a Ruby on Rails application to the new server. I ran into a few snags.

First of all, I followed their tutorial.

The default rails welcome page worked fine, but I kept getting “Application Error” on everything else. The logs showed nothing. I found several message board posts pointing to the permissions on the “public” folder.  Dr. Chuck had the best article on the subject.

Dr. Chuck’s instructions fixed the problem for a month or two.  Then it stopped working again. I figured some server-side process had changed the permissions on my files. So, I set it up again. It still didn’t work.

I actually had to contact tech support. A couple of days later they responded with the solution (thankfully, this isn’t a mission-critical app). Hostmonster had recently updated to a newer version of Rails. So, I just commented out the version in the rails environment file:

#config/environment.rb
#...
#RAILS_GEM_VERSION = '1.2.5' unless defined? RAILS_GEM_VERSION

I believe that tells the application to use whatever version of rails it can find (the most recent version on the server). Since version 1.2.5 had apparently been replaced with 1.2.6, removing the declaration for 1.2.5 fixed the problem.

The part that still confuses me is, I had tried generating the application from scratch while logged into the Hostmonster server (via ssh). Doing so still generated an environment.rb file for version 1.2.5.

Of course, the other part that confuses me is why did 1.2.5 stop working?  When I update my own servers with ‘gem update’, I keep old versions available for backwards compatibility of existing rails apps. As far as I know, there is no problem doing it this way. Am I wrong?

5 Responses

  1. I tried following the step given above, but receive the same error. Please guide.

  2. Sorry, I’m not sure I can help. I, too, had the same error pop up once more after Hostmonster helped the first time.

    This time, I instructed my client to deal with Hostmonster directly since there is little I could do.

    If they do provide another solution, I’d be interested in knowing what it is.

  3. The latest problem involved another upgrade. I hope they are notifying their customers of this kind of thing, but since I’m not their customer, it is hard for me to know.

    Anyway, the answer this time is in the blog post below:

    http://monsterails.wazoo.com.au/articles/2008/01/31/they-haved-destroyed-the-rails

    Change your .htaccess file to associate with fcgid instead of fastcgi.

  4. Hi Adam, Asghar,

    I remember getting an application error when HM upgraded from 1.2.5 to 1.2.6, but I’m not sure if it’s exactly the same as yours, however, here’s my solution (and one that DHH recommends as well). When hosting a Rails app in a shared hosting environment (like Hostmonster), always Freeze rails to your app:

    cd your_rails_app_folder
    rake rails:freeze:gems

    This places a full copy of the version of Rails you used with your app in your vendors folder. Then, whenever the host updates their rails, your app is still using your rails, so it won’t break if functionality is removed from rails in future versions. You can read DHH’s words about it here:

    http://weblog.rubyonrails.org/2006/3/31/freeze-is-cool-so-freeze-for-goodness-sake.

    Good luck and happy RoRing!
    tree

  5. Hostmonster as far as I can tell does not notify customers on upgrades. Maybe on their blog, I’ll ask my client if they received any email but I doubt it.

    I’m deploying a modified substruct application so I had to add gems and modify the gem path in my environment.rb file. And rails is frozen in the vendor directory so their upgrades won’t effect me. I have a capistrano task that changes the permissions. Capistrano has made this at least bearable.

    I have tried to talk to them about Passenger but to no avail. My app starts 103MB FastCGI processes when the page is hit and there is not much I can do except keep on them about Passenger.

Leave a comment