Mon, 14 Aug 06

Create rails projects using a specific rails gem version

I just found this when trying to create a rails project using rails 1.0.0 (having both 1.0.0 and 1.1.6 installed as gems).

If the first argument to the rails command is a valid (i.e. installed) version number and surrounded by underscores then that version of the gem is used to create the rails application structure.

So (with 1.0.0 and 1.1.6 gems installed)..

$ rails _1.0.0_ my-rails-proj
#-> uses rails version 1

$ rails my-rails-proj
#-> uses latest rails version (1.1.6)

Although you can normally place the rails libraries into the vendor directory of a given rails app (to use that specific rails version); I had problems when placing rails 1.0.0 into a rails 1.1.6 generated app. An error is encountered when trying to boot webrick..

./script/../config/../vendor/rails/railties/lib/initializer.rb:256:in `send': undefined method `cache_template_extensions=' for ActionView::Base:Class (NoMethodError)

By passing the version argument to the rails command and then placing rails 1.0.0 into the vendor directory, everything works as expected.