domingo, 11 de enero de 2009

Upgrade to Rails 2.2.2

When you have work on an application on you favorite language or framework, it is always good to know the new features of new release of it. But it is not always easy to migrate all your work and effort to the new version, so for all of you who have done something on rails 2.0 here are some pointer to upgrade to rails 2.2.2

If your application is simple rails with no plugin or gems require the upgrade is simple:

First you need to upgrade you rails version, rails 2.2.2 require gems version 1.3.0, therefore you need to verify you gems version first to do so gem -v command to see the gems version, if you have gems version 1.3.0 or higher you are ready if not the you need to update your gem first, that can be accomplish by executing

gem update - - system

as root or

sudo gem update - - sytem

If that does not work, then you can download the gem code and do a manual upgrade. Once you have the right gems version you can do upgrade your gems by the command line:

gem update or sudo gem update

This will update all your installed gems including rails and its requirements.

Then on you rails application path type

rake rails:upgrade

This will update your rails application with the new rails version

Now you need to change your enviroment.rb file and change the rails version line from

RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION


RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

When done you can start you server on development and see you application running with rails 2.2.2

If you have plugins you need to test and see if everything works as expected, some plugins like filecolum will break, giving you this error NameError (uninitialized constant FileColumn::ClassMethods::Inflector): it can be fixed by modifing the file file_column.rb from:


In active_merchand you need to comment out the infletor part of the file active_merchant/lib/active_merchant/billing/integrations.rb
In liquid you need to chage the ini.rb file to

ActionView::Base::register_template_handler :liquid, LiquidView 


ActionView::Template::register_template_handler :liquid, LiquidView   

If you have will_paginate as a plugin then you will have to remove it and use the gem version instead.

If you have started this project with rails 1.2.X and have used the pagination you will need to install classic_pagination plugin, but you will have to change this lines in order to make it work on rails 2.2.2
the file is pagination.rb
      options[:singular_name] ||= Inflector.singularize(collection_id.to_s) 
      options[:class_name]  ||= Inflector.camelize(options[:singular_name]) 
      options[:singular_name] ||= ActiveSupport::Inflector.singularize(collection_id.to_s)        options[:class_name]  ||= ActiveSupport::Inflector.camelize(options[:singular_name])