Upgrading to Rails 3

Hi All,

Re: Upgrading to Rails 3

I am working on a rails application I need to upgrade to the latest version of Ruby and Ruby on Rails.

It is currently using:

Ruby version 1.8.7 and

Ruby on Rails version 2.3.5

Is there any information, tutorial, guides etc. I can follow

Any help would be greatly appreciated

Kind Regards

Gurdipe

Check out

http://guides.rubyonrails.org/3_0_release_notes.html

It is my personal recommendation that you do three things:

  1. Create fresh new Rails 3 app for yourself to “play around in” first. In fact, you don’t even need to play much, you just need to compare your existing config files to the config files in your brand new rails app. Moving the Gem version of Rails doesn’t change config settings, and most of the Rails 3 good stuff is in config settings (like the asset pipeline.) When they say “it works this way by default in Rails 3” – they DO NOT mean you will get that behavior automatically just by moving the Gem version – they mean that when you do “rails new xyz” the default configuration on your newly created app is set that way.

  2. Don’t actually upgrade the existing repository. Instead, create a new Rails apps and copy files into it (Controllers, Views, Models, etc) one by one. This is more or less practical depending on your situation, so take this suggestion with a grain of salt. But if you do it this way, you can iteratively test as you make changes to confirm that each page and/or section of your app works.

  3. Consider upgrading to 3.0.9 without the asset pipeline first. Then when you have it working in Rails 3.0.9, enable the asset pipeline (in application.rb) and move all the way up to Rails 3.2.1 (or whatever the latest is)

Beyond that, expect to have to:

  • Rewrite your routes.rb file (there’s a new syntax)

  • Change instances of <% form_for … %> to <%= form_for … %> in views

  • Change “named_scope” to “scope” in models

There’s also an official upgrade path, but I don’t even recommend that either. You’ll learn more about Rails 3 and become a better developer if you do it piece-by-piece, following suggestion #2 above.

-Jason

Hi Gurdipe,

There is a series of RailsCasts that you can watch to get a reasonable idea of how to approach the upgrade.

http://railscasts.com/episodes?search=upgrading+to+Rails+3

Chirag http://sumeruonrails.com

Hi Jason,

Thanks for the awesome brilliant reply, it’s been a great help to me.

Gurdipe

Hi Chirag ,

Thanks mate, I’ll definitely checkout these rails casts out.

Gurdipe

Hi All,

Re: Upgrading to Rails 3

I am working on a rails application I need to upgrade to the latest version of Ruby and Ruby on Rails.

Make sure your automated test coverage is complete before you start, then you can be reasonably confident, when you have finished, that all is working.

Colin

Quoting Gurdipe Dosanjh <rhomobileapps@gmail.com>:

Hi All,

Re: Upgrading to Rails 3

I am working on a rails application I need to upgrade to the latest version of Ruby and Ruby on Rails.

It is currently using:

Ruby version 1.8.7 and Ruby on Rails version 2.3.5

Is there any information, tutorial, guides etc. I can follow

Any help would be greatly appreciated

In addition to the other advice, overriding ActiveRecord callbacks was deprecated in 2.3.8. So replace

  def before_save     # whatever   end

with:

  before_save :whatever

private

  def whatever     # whatever   end

HTH,   Jeffrey

I suggest you get your tests in gear if not already

get a core group (start with models, then controllers, minimum of models) passing in 2.3.5

then upgrade

you'll find a great number of plugins and gems will need to be upgraded - and some will have to be hand patched if you cannot find a suitable replacement Jodi

Hi Colin,

Thanks this point, I am also carrying out a exercise to ensure all the testing is checked and up to date.

Kind Regards

Gurdipe

Hi Jodi,

Thanks for this great point about testing and plugins that need to be upgraded. Its really helpful

Kind Regards

Gurdipe

Hi All,

Thanks to everyone for the great updates on how to upgrade to Rails 3.

What are the technical and business benefits of upgrading to the latest versions of Ruby an Ruby on Rails.

The application we have written is still on Ruby version 1.8.7 and Ruby on Rails version 2.3.5

Kind Regards and Thanks in advance

Gurdipe

Quoting Gurdipe Dosanjh <rhomobileapps@gmail.com>:

Hi All,

Thanks to everyone for the great updates on how to upgrade to Rails 3.

What are the technical and business benefits of upgrading to the latest versions of Ruby an Ruby on Rails.

The application we have written is still on Ruby version 1.8.7 and Ruby on Rails version 2.3.5

There are no bug or security fixes for 2.x. Nor if I understand the policy correctly, 3.0.x.

I'd suggest moving to 2.3.14 first before jumping to 3.x.

Jeffrey