Rails Subversion TNG – Using Edge and Other Versions

Using a newer version of Rails

There are a couple of ways of working with a newer version of Rails. The first is to use a ‘beta’ gem from the Rails beta gem server, and the second is to attach your working directory to a revision from the rails SVN trunk.

Use the beta gems server

Varying from regularly to occasionally the core team updates the rails gem files on the beta gem server. To see what revision the gems are currently at run:

gem list --so http://gems.rubyonrails.org --remote

To install a beta gem onto your system run:

gem install rails --so http://gems.rubyonrails.org -y

Attach to the Rails svn directory

A more precise method that allows you to vary which version of Rails you are using on a project by project basis, is to hook up your Subversion working directory directly into the Rails subversion structure.

There are a couple of reasons for doing this:

  1. To use the latest and greatest Rails features, or to lock a project onto a particular revision of the Rails code.
  2. To ensure that the version of Rails you developed the project with is the one you run the system on when deployed.

Attaching Edge Rails to your project

You attach a Rails version to your project by setting the svn:externals property on the vendor directory. Unfortunately the auto property setting facility doesn’t work to well with directories and svn:externals so we have to do this by hand.

Once you have created and committed a revision to the repository execute:

svn propset svn:externals "rails http://dev.rubyonrails.org/svn/rails/trunk/" vendor
svn update vendor

If you have started a new project, you probably want to update the file structure just in case Edge Rails has introduced something new:

rails . --force
svn add --force .
svn commit -m "Using Edge Rails"

You might want to consider locking to a particular revision if you don’t want your project to track all the changes in Edge every time you do an update.

Locking your project to a particular release of Rails

In addition to using the latest and greatest (and most fragile) version of Rails, you can lock your project onto a particular release.

All the released version of Rails have a tag name in the Rails Subversion directory. You can lock your project onto these versions just as easily as Edge, using precisely the same mechanism. For example if you absolutely have to have release 1.1.2 for your project to work use:

svn propset svn:externals "rails http://dev.rubyonrails.org/svn/rails/tags/rel_1-1-2/" vendor
svn update vendor

If however you just want to make sure that you are using the latest stable version of Rails you can lock your project onto the stable branch.

svn propset svn:externals "rails http://dev.rubyonrails.org/svn/rails/branches/stable/" vendor
svn update vendor

Locking your project to a particular revision of Rails

Edge Rails changes all the time, and there is no guarantee that what you get working today won’t be broken by the latest changeset tomorrow. Fortunately svn:externals allows you to specify which revision of the trunk you would prefer, e.g:

svn propset svn:externals "rails -r5322 http://dev.rubyonrails.org/svn/rails/trunk/" vendor
svn update vendor

You can find out what the revision number of the trunk is using the svn log facility:

svn log -qr HEAD http://dev.rubyonrails.org/svn/rails/trunk/

Create a free website or blog at WordPress.com.

%d bloggers like this: