Friday 28 June 2013

Upgrade Rails 3 app to Rails 4.0.0

Rails 4.0.0 stable version has been released recently, so you may want to upgrade an existing app to the new version of Rails.
First you might want to upgrade to the latest Ruby version 2.0.0, which is recommended with Rails 4. If you are using Ruby Version Manager (RVM), you do as follows:
$ rvm list known
NB. The RVM list should contain ruby-2.0.0. If it doesn't, then you may have to update RVM. You can follow the instructions from here
$ rvm install ruby-2.0.0
$ rvm use ruby-2.0.0 
Your rails app will now be using ruby 2.0.
You'll need to run bundle install to load your gems into the new ruby version.
$ bundle install
Now we can upgrade rails.

gemfile.rb

gem 'rails', '4.0.0'
$ bundle install
NB. If bundle install does work first of all, you may have to remove your Gemfile.lock and/or remove versioning from some of your gems so that dependencies are resolved.
I also found that I needed to update the railties gem.

You may also find that you get a Load Error when starting the rails server:

../config/application.rb:7:in `require': cannot load such file -- active_resource/railtie (LoadError)

If that is the case, then you will need to comment out/remove following line from application.rb:

require "active_resource/railtie"

If you do actually need active resource then it can still be added as a gem.

No comments:

Post a Comment