Using Capistrano to deploy your Rails app

1. if you haven’t got Rails installed locally then do it now. 

As of this blog post Rails 4, which you should be using, is pre-release so: 

gem install rails –pre

but drop the –pre when Rails 4 is no longer pre-release.

–pre means install the prerelease rails gem.

2. create a simple Rails app

rails new myapp

3. upload your Rails app to github

– create a git rep locally if it doesn’t exist

git init; git add .; git commit -am “first commit”

– create a github repo at 

This should tell you what you need to do next however in short:

git remote add origin

git push -u origin master

4. capify with

capify .

(and remember to push to git with:

git add .; git commit -am “with capistrano”

git push -u origin master)

Note: as you’re running Rails you should put your Capistrano config information in config/deploy.rb. So, your Capfile should look like this:

load ‘config/deploy’

and your config/deploy.rb file should have all the Capfile details like 

set :git_username, “your_git_username”

set :repository,  “”


5. Use SSH agent forwarding initially

Specifically, make sure you’ve got it set right locally:

6. Read also this post if you’re having problems with your ssh key:


default_run_options[:pty] = true

helps debug. And add your host to your known_hosts file by doing ssh and entering yes (it doesn’t matter that the login won’t succeed).


7. Then use:

cap deploy:setup 


cap deploy:cold

For more details of what deploy:cold does see:


Some issues:

I found Capistrano wasn’t creating directories in the releases directory with this option:

set :deploy_via, :remote_cache


To automatically run ‘bundle install’ on the server, add this to your deploy.rb file:

require ‘bundler/capistrano’

8. If using a Dreamhost VPS you may need to unset the DreamHost Managed Apache setting in VPS > Configure Server.

More on deploying Rails including details on Passenger (aka mod_rails), JRuby, Capistrano and Hosting:

Ruby on Rails with Apache and MySQL on Mac OS X Snow Leopard

Snow Leopard is a gnarly old beast.

However, I left my Mountain Lion laptop with someone when visiting and needed to use my old backup Mac running Snow Leopard.

Some hints on how to get stuff (MySQL / Rails) working:



ETag – reconfigure or remove

ETags (Entity Tags) are used to check if something (image, script, etc) in the browser’s cache matches the one on the server.

They’re an alternative to using Last-Modified Date.

However, as the default format included inode (for Apache) and server version (for IIS) it caused problems with large scale websites that have multiple servers as these would return a different ETag for exactly the same file just because it was on a different server.

The options are to reconfigure how ETag is set up in Apache / IIS or disable it. 

Another issue with including inode information in the header is security. Revealing this information can aid attacks on other network-based services:

Automatic Post Tagger

Not quite as awesome as an automatic post categoriser but still pretty handy: