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?
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?
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.
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
I found here an undocumented option to create a new application using an older version of Rails.
rails _2.1.0_ myapp
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.