Capistrano staging/production/demo recipe for precompiling assets

Problem

You have upgraded to rails 3.1.x, 3.2.x and you want capistrano to automatically precompile your assets and do the deployment in your various deployment environments (staging. production, demo etc).

Solution

First add a new directory in your server’s shared folder named assets

Then add the following line to your Capfile:

And finally have your deploy environment file (deploy/staging.rb | deploy/prodution.rb) as follows: