Ruby on Rails
EdgeRails

Be aware. This page has become highly inconsistent due to recent edits.

EdgeRails is a term which means you are running a local copy of a developmental version of Rails (i.e., you’re on the bleeding edge). It is an alternative to the more standard GemRails, which means you are running one of the stable releases (i.e., you installed it with the GEM packaging system).

The advantage to running EdgeRails is that you may get access to new features or bug fixes that are not in the most recent stable release. Also EdgeRails allows you to run on computer without Rails installed. Or you could run EdgeRails in a shared web hosting machine (see RailsWebHosts) that may only have the major releases installed on the system, but not the edge rails.

The disadvantage is that developmental versions are not generally regarded to be stable. So it’s a tradeoff.

In order to use EdgeRails you simply have to embed a (developmental) version of Rails within your application rather than using the version installed on your machine as a library. In that way, a developer working on multiple Rails applications can have some running off of GemRails, and others running off of various versions of EdgeRails, as these latter applications would have their own individual versions of Rails embedded within them.

To embed a version of Rails within your application, the relevant files are copied into the vendor/rails directory.

The Easy Way

Simply use this command from your application home directory to unpack the latest edge rails into your application vendor/rails directory:


rake rails:freeze:edge

This embeds the Rails framework into your application by using Subversion (svn) to copy the files from the developmental source code repository (dev.rubyonrails.org) into your vendor/rails directory. Subversion is necessary even if you are not using it to manage the source code of your own project.

If you would like to run a specific revision of EdgeRails, then you can refer to it on the command line. For example, this command would embed version 1234 of Rails into your application:


rake rails:freeze:edge REVISION=1234

Hint: Instead of bleeding edge, you may want to freeze the latest stable code. You should also check it into your Source Control system, so that you can revert back both to your app source as well as the stable rails version it worked with at any future date.
Visit http://dev.rubyonrails.org/browser/branches
to figure out the revision for the stable branch. Then you can use the above rails:freeze:edge REVISION=#### command to freeze the stable branch to your app.

To revert to GemRails, issue the command:


rake rails:unfreeze

That command empties the vendor/rails directory.

A third option is to issue this command:


rake rails:freeze:gems

That command copies GemRails into the vendor/rails directory. This might be useful to you if you do not have Rails installed as a library on your system.

Tracking Rails as it is Developed

Piston is a utility that eases vendor branch management. This is similar to svn:externals, except you have a local copy of the files, which you can modify at will. As long as the changes are mergeable, you should have no problems. Some pros over using svn:externals is that you always have everything in your own repository, making it faster to checkout or checkout at all if the rails repository is down for some reason.

Installation:

$ gem install --include-dependencies piston
Successfully installed piston, version 1.0.0

For those of you who do not want to use piston, or are looking for the old instructions (sans piston), please see version 164 of this file.

First, you need to import the remote repository location:

$ piston import <a href="http://dev.rubyonrails.org/svn/rails/trunk">http://dev.rubyonrails.org/svn/rails/trunk</a> vendor/rails
Exported r4720 from 'http://dev.rubyonrails.org/svn/rails/trunk' to 'vendor/rails'

$ svn commit -m "Importing local copy of Rails" 

When you want to get the latest changes from the remote repository location:

$ piston update vendor/rails
Updated 'vendor/rails' to r4720.

$ svn commit -m "Updates vendor/rails to the latest revision" 

You can prevent a local Piston-managed folder from updating by using the lock subcommand:

$ piston lock vendor/rails
'vendor/rails' locked at r4720.

When you want to update again, you unlock:

$ piston unlock vendor/rails
'vendor/rails' unlocked.

Already using svn:externals? Don’t worry, it’s easy as applepie to convert. Just follow the instructions on here

Switching from GemRails to EdgeRails

If you’re currently using GemRails and want to switch to EdgeRails instead, first you set up svn:externals using above technique. Besides that, you’ll also need to upgrade certain files in your application to be compatible with Edge Rails.

There are several ways to do so. The overall idea is to get to know which files to upgrade!

One way to find out which files is to generate a new temporary Edge Rails application. To do so, create a temporary directory and do this (don’t do this in your app folder):

  $ ruby /path/to/project/vendor/rails/railties/bin/rails .

This will create a new rails application directory tree. See which files it created? Chances are, these are the ones you might need to upgrade in your application. Make sure not to forget to merge any of your changes, especially to application.rb, environment.rb, database.yml and the like.
There’s no need to check-out another copy of rails for this.

Question: Is it necessary to overwrite the gem files if you are running edge rails inside your vendor directory? I thought that rails just looked in vender first and ran from there if it found rails there.

Answer: Rails does run from vendor/rails. However, what people here mean is that you need to update the files in your application for compatibility with edge rails. Just like you’d have to update some of your application files when upgrading from 0.13 to 1.0.

For example the dispatch. scripts inside your public/ folder need to be updated to be compatible with edge rails as even between 1.0 and revision 3595 there are incompatibilities. – Tal Rotbart

Rake problem
In case anyone is encountering a problem like…


[duane@mail1 socialconference]$ rake -T
  (in /home/www/socialconference)
  rake aborted!
  undefined method `namespace' for main:Object
  ./Rakefile:10

try to update rake via

sudo gem update rake

this should resolve the problem. -namxam? via Going Up

Tip*
If you get an error “no such file to load…” then maybe your rails edge installation was partial,—delete vendor/rails and start over.