Upgrading from rails 4.0 to 4.2

Hi Guys,

I have a Rails app that I want to upgrade from 4.0 to 4.2.

How would you go about doing this? Would you create a new branch and do it that way and if it all goes wrong delete it?

Any ideas will be helpful.



If you get stuck, @seangriffin is our resident Rails master.

I suggest going up incrementally by the latest version of each ‘minor’ release, i.e. 4.0.13, then 4.1.10, then finally 4.2.1.

Upgrading Ruby on Rails — Ruby on Rails Guides has very useful, detailed instructions.

Thanks guys, if it all goes to plan do you just merge the branch into master?

I’d recommend deploying the branch to a staging environment first if the app is for anything important.


I would also check RailsDiff

It’s a great app that shows the difference between your source Rails version and the target Rails version.

I used it lately when I was upgrading from Rails 4.1 to Rails 4.2, and RailsDiff was a great help.

hope this helps,


1 Like

A piece of good news is that it seems to be getting easier and easier to upgrade Rails versions. 4.0 → 4.1 was only mildly painful on the apps I maintained, and 4.1 → 4.2 was so easy that I was worried that something was very, very wrong with my test suite when I updated.

I would always just take a peek at the blog post the core team writes when the release comes out. They break down the big changes by Rails component (ActiveRecord, ActiveSupport, ActionMailer, etc), so you can scan it and look for trouble spots that might be relevant to your app.

@acandael I am changing the files mentioned in the RailsDiff website between 4.0.0 and 4.1.0 and one of the changes is -Railsdiff::Application.initialize! to +Rails.application.initialize! however when I do this changing Rails to my app name I get undefined method 'application' for Aas:module

Any ideas?


Turns out it’s because I was changing it to Aas when it is infact Rails now.

@seangriffin I am using spring now and I get this error when running bin/rake routes

env: ruby.exe: No such file or directory

I am using rvm on OS X Yosemite so I don’t know if I need to do anything extra?

If I do spring rake routes it’s fine.


That’s strange, can you post the contents of the bin/rake script?

#!/usr/bin/env ruby.exe
  load File.expand_path("../spring", __FILE__)
rescue LoadError
require_relative '../config/boot'
require 'rake'

I guess it has something to the shebang at the top, but I havn’t changed anything I jhave just done bundle install and then bundle exec spring binstub --all

What should it be?


@andyw8 I have just created a new rails app to see what it set the bin/rake script to and it’s #!user/bin/env ruby so I changed it to that and it’s working now. I have no idea why it added .exe to it :confused:

They were all set to ruby.exe except for the spring one :confused:

Thanks for your help :smile:

Good to hear. It looks like the app might have been configured to run on a Windows machine at some point in the past?

Yes I work on the app from a windows machine every now and again.