Upgrade to Rails 3.1 and deployment

Firstly i would recommend to read the RailsCast about Upgrading to Rails 3.1.

When you’ve done that, you can also update some other gems in your Gemfile. There came up to some issues that the railscast does not cover, so have a look at these simple solutions:

Embed images via Javascript

in my application.js I’ve added one image hardcoded with html:

This won’t work as our application’s images (as described in the railscast) – so I’ve simply created a css class where I embed that image. The helper method for the right image path in CSS is image-url:



Deployment with Capistrano

I’ve updated capistrano to the newest version (2.11.2). Capistrano (v2.8.0 and above) includes a recipe to handle this in deployment. The only thing you need to add in your Capfile is the following line:

Further reading: http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

Could not find a JavaScript runtime

During the deploying the following error occured: „Could not find a Javascript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)“

So I added the therubyracer gem to my Gemfile – and it worked!

Individual CSS files

I am working with a responsive webdesign grid (1140px grid). Therefore I want to have 3 different compiled CSS files: screen.css, mobile.css and one CSS for IE specific adjustments. If you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the precompile array in your production.rb:

Right Permissions on Server

I’ve successfully deployed my upgraded app, but I was getting a Permission denied error on all assets files. That’s because my Apache2 user on my server doesn’t have the permissions to read these files, only my deploy user has had these permissions.

To see which user runs my Apache2 process I’ve done the following:

so i’ve add this user to the group that have the right permissions:

Allow Symlink on Server

A symlink from current/public/assets to shared/assets is automatically created. So you have to allow that in your VHost file:



If you successfully upgraded to Rails 3.1 you definitely have no problem to upgrade to Rails 3.2!

Schreib einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *