Upgrading PriceChirp from Rails 2.2.2 to Rails 2.3.3
Today I updated PriceChirp from rails 2.2.2 to rails 2.3.3. It was easier than expected, but I ran into several gotchas along the way. Here's an outline of the major issues I encountered and how I addressed them. Depending on your code, this may or may not be any any use. Note: Several of these steps had to be performed on both the development and production boxes.
1) Updating gems
To upgrade the base system gems, as root I ran:
gem update
This upgraded the system gems such as rails, mysql, passenger, etc. The gems built into PriceChirp in the /vendor/gems directory had to be updated separately. I'll get to those in a few minutes.
2) Updating passenger
Once the passenger gem was updated, I ran .../gems/passenger-2.x.x/bin/passenger-install-apache2-module. The passenger developers have done an excellent job with the on screen documentation. Really, the only step is to watch passenger compile for a few moments and copy two lines they provide into the Apache configuration and restart Apache.
3) Rails 2.3.3
In config/environment.rb I fixed the rails version number to 2.3.3:
RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
4) OpenIdAuthenticationNow it's time to run "rake spec" to see how bad things are. My only output is:
rake aborted!
uninitialized constant Rails::Plugin::OpenIdAuthentication
Yikes.. What does this mean? After some google searching I get hints on patches. Really, the best thing to do is to install the latest version.
script/plugin install git://github.com/rails/open_id_authentication.git –force
I return to rails 2.2.2 version to test things out. The site seemed to work, however, when I attempted to log in via openid, I would get the following:
Sorry, the OpenID server couldn't be foundTo get around this, I upgraded to the latest version of ruby-openid. As of this post, I used version 2.1.7.
5) Other gems / plugins to update
Other frozen gems / plugins that caused me problems and had to be updated for rails 2.3.3 included: rspec, rspec-rails, and asset_packer.
6) Rename app/controller/application.rb
Rails 2.3.3 renamed the application controller from app/controller/application.rb to app/controller/application_controller.rb to be consistent with the other controllers.
7) Fixed minor rspec errors
I had to fix a few minor rspec issues to get things to pass tests. None of these problems were issues with the code, rather they were issues with how rspec has changed the way it handles the test cases. Since they are specific to PriceChirp and only impact "tests", I'm glossing over this step.
8) sort! is gone
My last issue was the new ActiveRecord object returned from the count method no longer has the sort! method.
a = Item.count(:user_id, :group => :user_id)
a.sort! {|x,y| y.second <=> x.second}
no longer works.
To get around this, I did the easy
a = Item.count(:user_id, :group => :user_id)
a = a.sort {|x,y| y.second <=> x.second}
There may be a way to get the count method to sort the way I want it to, but this was an easy quick fix.
9) deploy
After testing, all that was left to do was, "cap deploy" and watch the magic happen.
Conclusions:
The upgrade from rails 2.2.2 to 2.3.3 was fairly painless. I broke this into several steps and committed each one into my code repository along the way. I also ran my spec tests after each step to ensure I was not causing too many problems.
Good luck!