Translations of this page?:

Upgrading an Existing App

Update Rails and gem

First, you'll need to update Rails and Ruby gem to the desired version. Briefly:

$ sudo gem install rubygems-update
$ sudo update_rubygems

and:

$ gem install rails
OR
$ gem install rails --version "=2.2.2"

Preparing your SCM

If you're using a SCM with powerful (and easy) branching such as Git now might be a good time to make a new branch of your app that you can use to keep your upgrade work separate from the main branch. When your upgrade is finished you can merge that work back in.

$ git checkout -b rails23upgrade

Pin your app to a newer version

Update your environment.rb to reference the version of Rails you're upgrading to:

RAILS_GEM_VERSION = '2.3'

Then use the built-in rake task to update your configs, javascripts, and bootstrap.

$ rake rails:update

Update plugins

You can upgrade your plugins simply by removing the older plugin and installing a newer one in it's place:

$ rm vendor/plugins/fancy_plugin
$ ./script/plugin install fancy_plugin

Of course you may have to change some of your app code or configuration to support the new plugins.

Dealing with Rails changes

If there is anything constant about Rails it's that it's constantly changing. You may want to read the release notes of the various Rails versions to find out what's new:

If you're updating from a very old version 1.0 you might have a lot of work to do.

Remove deprecated code

As core gets leaner and meaner sometimes features are removed, renamed, or deprecated. You may need to update your app to using a new method or convention.

Often plugins are available for features that have been entirely removed from Rails core:

Take advantage of new features

Each new version of Rails packs more and more punch. Many features now in standard in core were previously available as plugins:

  • dirty tracking
  • timezone support (via TzTime)
  • named scopes
  • localization

If a newer Rails version has added core functionality that you've been using a plugin for it's probably time to throw that plugin out and switch to the Rails core functionality instead.

Run your test suite

Now run your comprehensive test suite. Does everything pass? Pat yourself on the back. If not time to go bug hunting!

Discussion

Onur Ferhat, 2009/10/22 23:21

I changed the “Run your test suite” topic's level and put it under “Dealing with Rails changes”, but I'm not sure whether I'm mistaken.

 
getting-started/upgrading.txt · Last modified: 2009/10/22 23:19 by tiendan
 
Recent changes RSS feed Creative Commons License