views:

1454

answers:

4

I have two versions of rails (2.1.0 and 2.2.2) installed in my computer.

When I create a new application, is it possible to specify that I want to use the older (2.1.0) version?

+5  A: 

You can generate the skeleton with either version and require the one you want in config/environment.rb:

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION

or use the "rails" command form the version you want anyway.

Keltia
+2  A: 

You should also take a look at "freezing" your Rails gems into the app. This helps a lot with deployment, specially in shared hosting environments.

Just change the RAILS_GEM_VERSION variable in config/environment.rb and issue the freeze rake task:

rake rails:freeze:gems
Thiago Arrais
+10  A: 

I found here an undocumented option to create a new application using an older version of Rails.

rails _2.1.0_ myapp
hectorsq
awesome, thanks
BenB
+1  A: 

hectorsq has the best answer here. I had a situation where I needed to run an app with Rails 1.2.5. Specifying the version in the environment file (as suggested by Keltia) won't work if there has been significant changes in some of the files generated by rails like boot.rb.

schlick