Sunday, March 22, 2009

What I did when upgrading from Ruby on Rails 2.2.2 to 2.3.2

I write what I had to do to upgrade Ruby on Rails from 2.2.2 to 2.3.2.
Development machine is Mac OS X Leopard and production server is Ubuntu Hardy.

1. (development machine) Update Ruby on Rails.

$ sudo gem update rails

2. (development machine) Update all the gems.
(Note: 1. above can be done in one shot in here. But I'm just writing following the order I did as much as possible.)

$ sudo gem update

3. (development machine) Under RAILS_ROOT for the Ruby on Rails application, execute rake to update Rails.

$ rake rails:update

This updates the following files:


4. (development machine) In the Ruby on Rails application, rename application.rb to application_controller.rb.

5. (development machine) In the Ruby on Rails application, in environment.rb, change the version to 2.3.2.

6. (development machine) Installe system_timer gem.

$ sudo gem install system_timer

This is because of a warning when script/server:

[memcache-client] Could not load SystemTimer gem, falling back to Ruby's slower/unsafe timeout library: no such file to load -- system_timer

7. (development machine) In ApplicationController, comment out:

session :session_key => '_session_id'

because of the warning in script/server:

DEPRECATION WARNING: Disabling sessions for a single controller has been deprecated. Sessions are now lazy loaded. So if you don't access them, consider them off. You can still modify the session cookie options with request.session_options.

8. (development machine) In environment.rb, change as following based on what's written in release note (


config.action_controller.session = { :session_key => '_some_session',


config.action_controller.session = { :key => '_some_session',

I use RedCloth and followed what is written here ( to make it work.
But after the fact, only the steps 1 to 5 above should allow the application to start with script/server.

The following are the steps to make RSpec work.

9. (development machine) In routes specs, change :id => 1 to :id => '1'.
Also for nested routes, do the same thing e.g. :register_id => 1 to :register_id => "1"

10. (development machine) For the controller method that takes care of javascript, which doesn't have a corresponding .html.erb file, add:

:format => 'js'

for get in spec. e.g.

get :index, :format => 'js', :topic_id => "1",
:selected_sub_topic_id => "2"

This is because even though controller spec is separate from view, RSpec couldn't catch up with the change in Ruby on Rails, and the existence of the corresponding .html.erb is required.

11. (development machine) RSpec correctly detects OrderedHash instead of array of array. Ruby on Rails returns OrderedHash for group_by. So change such as following:

[ [ mock_jurisdiction, [ mock_bulletin ] ] ]


{ mock_jurisdiction => [ mock_bulletin ] }

Note: As far as I observed, Ruby on Rails itself was already using OrderedHash in 2.2.2 but RSpec was failing if I use the Hash format. Now it fails with array format.

The following is a step to make CruiseControl.rb (fork with GIT support) work.

12. (continuous integration server) Delete all the unpacked gems in .cruise/projects/RAILS_ROOT/work/vendor/gems because CruiseControl complains such as

config.gem: Unpacked gem RedCloth-4.0.1 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.

even after unpacked gem is removed from the Ruby on Rails application itself.

The following is a step to make Capistrano work.

13. (production server) Update all the gems. (Actually this had already been done as a part of Ruby on Rails upgrade in production server.)

$ sudo gem update

14. (development machine) Under RAILS_ROOT for the Ruby on Rails application,

$ script/plugin install

because commands/process/spawner that is used Mongrel is deprecated. (

No comments: