Friday, December 10, 2010

How to upgrade from Rails 3.0.0 to Rails 3.0.3.

On November 15, 2010, the Rails team released Ruby on Rails 3.0.3. If you've already upgrade to 3.0.0, here's how to upgrade to the newest release.

First, check what version of rails you're currently running. From your application folder (mine is ~/wikidiscography), type rails -v. For my application that returns Rails 3.0.0.

Now check your Gemfile (mine is at ~/wikidiscography/Gemfile), and find the line that should read something like gem 'rails', '3.0.0'.

First, try removing the version argument (everything after the comma), so the new line should just read gem 'rails'. Then, from the command line, run $ sudo bundle install and see if it installs the latest version of Rails. My truncated result: ... Using rails (3.0.0) ... Your bundle is complete! .... So removing the version argument does nothing.

Next try adding the version argument back in to your Gemfile with the latest version of rails, 3.0.3: gem 'rails', '3.0.3'. Note that we've changed "3.0.0" to "3.0.3". Now save the file and run $ sudo bundle install again. This takes about 30 seconds to run.

My result:

andy@andy-laptop:~/wikidiscography$ sudo bundle install
Fetching source index for http://rubygems.org/
You have requested:
  rails = 3.0.3

The bundle currently has rails locked at 3.0.0.
Try running `bundle update rails`
Fair enough. Let's do what it suggests, and run 'bundle update rails'. I'm also interested in why and how my bundle has locked the application at 3.0.0. From the command line: $ sudo bundle update rails. Again, this takes about 30 seconds. My result:
andy@andy-laptop:~/wikidiscography$ sudo bundle update rails
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Installing activesupport (3.0.3)
Using builder (2.1.2)
Installing i18n (0.5.0)
Installing activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Installing rack-test (0.5.6)
Using tzinfo (0.3.23)
Installing actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Installing treetop (1.4.9)
Installing mail (2.2.12)
Installing actionmailer (3.0.3)
Installing arel (2.0.6)
Installing activerecord (3.0.3)
Installing activeresource (3.0.3)
Using bundler (1.0.0)
Using diff-lcs (1.1.2)
Using factory_girl (1.3.2)
Installing thor (0.14.6)
Installing railties (3.0.3)
Installing rails (3.0.3)
Using factory_girl_rails (1.0)
Using gravatar_image_tag (0.1.0)
Using nokogiri (1.4.3.1)
Using rspec-core (2.1.0)
Using rspec-expectations (2.1.0)
Using rspec-mocks (2.1.0)
Using rspec (2.1.0)
Using rspec-rails (2.1.0)
Using sqlite3-ruby (1.3.1)
Using webrat (0.7.1)
Using will_paginate (3.0.pre2)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.

So this has installed the 3.0.3 version of all the modules that make up rails (activerecord, activeresoruce, actionmailer, etc). Now if you run from the command line $  rails -v you should get the return Rails 3.0.3.

Now try restarting the server with $ rails server. The result:

andy@andy-laptop:~/wikidiscography$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-12-10 12:23:05] INFO  WEBrick 1.3.1
[2010-12-10 12:23:05] INFO  ruby 1.8.7 (2010-01-10) [i486-linux]
[2010-12-10 12:23:10] INFO  WEBrick::HTTPServer#start: pid=4872 port=3000
According to the output, I am now running a Rails 3.0.3 application.

To recap:
  1. Check your Rails version from the command line: $  rails -v
  2. Modify your Gemfile to the latest rails version: gem 'rails', '3.0.3'
  3. Run Bundler's updater: $ sudo bundle update rails
  4. Restart your application's server.
  5. Done (if all your test are passing).

No comments:

Post a Comment