Menu

I started a Ruby on Rails project with Rails version 3.2.12. But i did not really much in this project because of my time. My day has not enough hours 🙂 I played around with TeamCity and Jenkins as CI server and how i can deploy it to EC. How to setup everything on AWS EC2 and so on. Now, i just found out that there Rails 4.0.0.beta1 ist out. So i thought, why not update to Rails 4.0 and then start with the project 🙂 So, here is how i get there.

I will describe how you create your own Gemsets, update to Ruby 2.0 and Rails 3.2.13 and then to 4.0. Gemsets are pretty useful, because this way you can switch the versions without problems. Its true, i tried it 🙂 We will also create a .rvmrc file to specify which Gemset should be used in this project. So lets start with it 🙂

Lets assume you have Ruby 1.9.3-p392 and Rails 3.2.12 installed and created a project like this:

1

2

3

$rvm install ruby-1.9.3-p392

$rvm use1.9.3--default

$rails newmyApp

So we have a clean Rails project. So it looks similar in my project 🙂

Update Gems

So, lets check if we have the correct versions for Ruby 2.0 and Rails 4.0

1

$gem-v

We will need RubyGems 2.0.3 or newer, so update if you have an older Version:

1

$gem update--system

check for other versions with

1

$gem list

you will need the following versions:

RubyGems 2.0.3

Rake 10.0.3

Bundler 1.3.4

Rubygems-Bundler 1.1.1

update it with following commands:

1

2

3

4

5

$gem update rake

$gem update bundler

$gem update rubygems-bundler

Create Gemset for our existing Application

If you never created a Gemset, you are using propably the default or global one. Check with:

Rake Rails:Update

Minor Rails version updates seldom require changes to configuration files. Major Rails updates often change configuration files. If you don’t make the required configuration file changes, you’ll likely see deprecation warnings when you launch a Rails application.

Rails provides a rake task to update configuration files. Be sure you’ve committed your application with git before running rake rails:update in case you need to roll back changes.

1

2

$git commit-m'before rake rails update'

$rake rails:update

The rake rails:update will identify every configuration file in your application that differs from a new Rails application. When it detects a conflict, it will offer to overwrite your file.

Don’t blindly allow rake rails:update to overwrite your files. Many of your files will be different because you’ve made changes from a default new Rails application. You’ll need to check each file to determine if rake rails:update is seeing your own changes or pointing out changes due to a Rails update.

When rake rails:update offers to overwrite a file, enter d (for “diff”) and review the differences. Most differences will be your own. If you’re uncertain, don’t overwrite the file; make a note for yourself and investigate later. If you are certain that the difference is due to a Rails version change, you can allow rake rails:update to overwrite the file.