Many Shared Hosting Plans have been upgrated to Rails 3.0.3 on Dreamhost and this “Christmast Gifts” caused pain and frustration to a lot of people even if the dh support deny this #fail (Search “dreamhost rails ” on Twitter).

Anyway this migration killed Rails 2.x (and Rails 3 beta4), but now Passenger (2.2.9) and Rack (1.1) are updated.

Yay, You should test your webapps in a production environment on your local machine before deploy you code in DH, but it isn’t enough because on Dreamhost with Phusion Passenger as Web Server the things could work differently.

So here a collection of the issues you could get.

Sqlite3 and the default rails app on Dreamhost

If you try a default test app with rails on DH it is broken, because it requires sqlite3 1.3.0 which doesn’t compile. You can force the downgrade to the gem 1.2.5 or use ‘mysql2’.

# Gemfile

gem 'sqlite3-ruby', '1.2.5',:require => 'sqlite3'

Javascript an other static files are not loaded

This problem occurred also on Heroku, you have to change a config parameter.

# config/environments/production.rb

# Disable Rails's static asset server

# In production, Apache or nginx will already do this

# ..IHMO No.

config.serve_static_assets = true

Other files won’t be loaded in production

The lib/ or other paths won’t be loaded in production, you have to be explicit.

# config/application.rb

config.autoload_paths += %W(#{config.root}/lib)

Bundler says: “You have modified your Gemfile in development but did not check”

rm -rf .bundle && bundle install && git add Gemfile.lock && git commit -m "Added Gemfile.lock

Yikes! One of your processes (bundle, pid NNNN) was just killed because your..

If bundle is killed often is better to run ‘bundle pack’ in your dev environment, move Gemfile, Gemfile.lock and vendor/ in production DH and exec ‘bundle install --deployment’ to recreate the same gem set.

Some gems couldn’t work (eg uuid)

Dreamhost allow you to customize a lot your shared hosting, but some features could not be avalaible. The gem ‘uuid’ generates universal ids with ifconfig or ipconfig commands which aren’t avalaible. Use ‘simple_uuid’.

The config.ru done right

require ::File.expand_path('../config/environment', __FILE__)

# you cool stuff, use x,y and require y,z

run MyApp::Application

That's all, enjoy