A Note About Rails Versions 3

Jeffrey Hardy,
Dec 18, 2007

As some of you may be aware, Rails 2.0 was recently released. This is a huge milestone for the Rails project, but it introduces a few changes that are sure to trip up readers.

The book was written for Rails version 1.2.3

That’s right. When the book was written, Rails 2.0 was merely a glint in the core team’s eye.

Generally, a release that increments the major version number (as in Rails 1.x to 2.0) will include breaking changes, and Rails 2.0 is no exception. With this latest release, the core team has been really aggressive in terms of removing features. Some of the nice-to-have features like scaffolding and pagination that we wrote about in the book are no longer part of the core framework but are available as plugins instead.

Installing and using Rails 1.2.3

If you want your sailing to be smooth, I recommend installing and using Rails 1.2.3 as you go through the examples in the book. Here’s how you would go about installing version 1.2.3 via RubyGems and telling your application to use it:

  1. sudo gem install rails -v 1.2.3
  2. open config/environment.rb and make sure the RAILS_GEM_VERSION is set to 1.2.3:
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '1.2.3'

You’ll no longer need to worry about installing the scaffolding or pagination plugins because they’re both alive and well in Rails 1.2.3.

You can also elect to freeze a copy of Rails into your project’s vendor directory, which will take precedence over the Gem version you’ve specified. Rails makes this easy with a bundled Rake tasks:

$ rake -T | grep freeze
rake rails:freeze:edge  # Lock to latest Edge Rails or a specific revision with REVISION=X
rake rails:freeze:gems  # Lock this application to the current gems (by unpacking into vendor/rails)
rake rails:unfreeze     # Unlock this application from freeze of gems or edge and return to a fluid use of system gems

As you can see from the comments, you can freeze to either the edge version of Rails, or a specific revision from the repository. You can also freeze to whatever Gem version of Rails you have installed on your system.

This is often called the vendor everything approach.

What about the future?

Take heart. Most of the changes are minor enough that you won’t have any trouble transferring your knowledge to Rails 2.0. By the time you’ve finished the book, you’ll have a much better understanding of Rails, and to be sure, the fundamentals haven’t changed.

The new and refined features of Rails 2.0 have only made it better.

Comments

Leave a response

  1. EvanDecember 27, 2007 @ 11:22 AM

    Hi there. I am just beginning with your book, so spare my ignorance on this one. BUT, is it satisfactory to simply install rails 1.2.3 (using the method described in your post), and then create applications for the purpose of following along with the book using the command ‘rails 1.2.3 appname’?

    Also, could you shed some further light on the purpose of freezing a version of rails to a specific app?

    Your help is appreciated.

  2. EvanDecember 27, 2007 @ 11:26 AM

    Whoops. There should be underscores to each side of the rails version number in the command from my last post – looks like mephisto stripped them out or somethin.

  3. Jeffrey HardyDecember 28, 2007 @ 12:54 AM

    @evan: Yep. Just like you say, to generate a skeleton from any version of Rails that you have installed via gems, just pass along the version number:

    $ rails _1.2.3_ my_application
    

    The main reason you might want to freeze a version of Rails into your app is so that it will not be dependent on the system gems you have installed.