How to upgrade a Rails application to use the latest version of Rails

I am working on a Rails application that currently uses Rails 1.2, so now I'm pretty far from the latest stable version (Rails 2.3).

How do I upgrade to a new version of Rails?

Should I update the release of one point at a time or immediately to Rails 2.3?

How to find out what has changed between versions of Rails, how

  • improvements or new features that give me more reasons to upgrade
  • Changes to Rails that require me to modify my application before it works with the new version.

(I saw this question about the update mechanism, but I'm more interested in the process that I have to go through to make the update as painless as possible.)

+4
source share
7 answers

I went through this a few months ago, did a lot of research, and put together a rake task (based on someone else's script plus additional resources) that could help you flag changes in the code. This was for upgrading to Rails 2.2, so it does not account for Rails 2.3 changes:

http://gist.github.com/99535

Remember to check that the plugins and stones you use are compatible with Rails 2.x and use the latest versions.

And I definitely agree to upgrade directly to Rails 2.3 at a time. And do not leave it; the longer you go without updating, the harder it will be, as more will be changed. And it's harder to support Rails 1.x, as there are fewer resources.

+4
source

My advice is to spend a week paying off any testing arrears that you have accumulated, and then do the update in one fell swoop.

Where I work, we updated a very large application from 1.2 to 2.0.2 last summer and at the same time updated to Ruby 1.8.6.

MUCH MORE was more than expected. The application used several old functions that were removed or deprecated (for example, ActionWebService), so it took some time to convert them. But basically, we came up with a lot of subtle bugs, such as small differences in how the switch options work, some of which were related to the Ruby update (versus Rails).

In some parts of the application there was a spotty coating. If we went into it with the best tests, everything would be much simpler.

+2
source

I just started updating the Rails 1.2.3 application in a Rails 2.3.4 environment. The main steps and warnings that I came across:

  • Create a skeletal application similar to your base application
  • Check the environment.rb settings that you have in the old application to see if they are required in the new version.
  • Transfer all .rhtml files to .html.erb; either using a script or manual. In my case, there were more than 100 files, so automation was easier.
  • Note any changes to routes.rb that might be required, given that RoR2.3.4 made route determination easier.
  • Make sure you have a good SCM system; for example, Git, SVN, or even CVS, so that you can capture small incremental changes.
  • Check which plugins you need. At the beginning, I simply deleted all the plugins, and in fact some of them were deprecated for the functions that should have been implemented in the ported application.
  • Update any form_tag entries; for example <%= form_tag :action => 'search' %> becomes `<% form_tag: action => 'search' do%> otherwise you will get interesting error messages
  • Similarly, change <%= end_form_tag%> to close the block, as in `<% end%>
  • Check if you have plugins in version 1.2.3, which are now removed from the kernel and should be installed as plugins and configured for dependencies. I am having problems with in_place_edit and calls made in the calendar popup.

As others have said, this may take longer than expected. I worked about 30 hours of work on migration. I calculated that it would take much longer; so it was good; but there is still one more work to create PDF generation.

To make it more interesting, the application was run in an MS-Windows environment; Ruby 1.8.7, Rails 1.2.3 and MS SQL Server. The goal was to switch to a Linux environment; Ruby 1.9.x, Rails 2.3.4 and the MySQL database, so the MySQl server database migration tools were used.

+2
source

I think there are some Rails Rake tasks you could get that would look for deviations in your application.

And while your application is in version control, I’ll do the update in one shot and skip the error messages one at a time.

In addition to the release notes pages that you saw in versions 2.2 and 2.3, there should be release notes or change logs in the source itself. In addition, you can search for blog posts (use the Google Blog Search) with search terms such as “rails xxx new features”, etc.

+1
source

I’ll start by answering my question with the resources I managed to find in my Googling. Rails 2.2 release note and Rails 2.3 release note provide details on the new and changed features in these two versions, but I cannot find anything final for the earlier releases.

I also didn’t know much about what will break during the upgrade, except for this release announcement , which mentions that older versions of Passenger won. Don’t work with Rails 2.3.

0
source

I found that these documents were missing a few details, and the transition from 2.1 => 2.2 took quite a while. Here are my notes:

Biggest time: assert_redirected_to has changed significantly, no longer hashes (in general?)

You must also set environment/test.rb to disable fake protection.

If someone got the news on these items for 2.3, that would be super surprising.

0
source

You probably had a lot of experience with this at the moment, but I came across this while looking for another question with the Rails 1.2> 2.3 update and thought that I would do a little advice myself:

The biggest gap I had in a relatively simple application was pagination. I found the Classic Pagination plugin for this purpose.

0
source

All Articles