Sunday, July 06, 2008

How To: Create old rails apps when you have newer gems installed

My dev server has the gems for rails 1.2.6, 2.0.2 and 2.1.0 all installed.

You can see which ones you have by running

gem list --local | grep rails

The problem is, when I create new rails apps, it always uses the latest version. If I explicitly want to create a 1.2.6 or 2.0.2 app, then I can do it like this

rails _1.2.6_ some_old_app

Useful.

For the technically nosey, we can see how this works by reading the source of /usr/bin/rails, which is here

require 'rubygems'
version = "> 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end
gem 'rails', version
load 'rails'

1 comment:

Sophia said...

Within the next two weeks we discussed shooting a video with the help of Ian's iMovie software and high definition video camera moldavite