views:

52

answers:

4

I had Rails 2.3.5 installed, and wanted to upgrade to 2.3.10 as a stepping stone to Rails 3. I thought running gem install rails -v=2.3.10 would install 2.3.10 and keep 2.3.5 as well. But now when I do Rails -v, it only lists Rails 2.3.10. How can I install different versions of Rails and keep the existing ones?

A: 

You can define the Rails version of an application in config/enviroment.rb.

Ashley Williams
+3  A: 

gem list rails should show you all installed versions of Rails. You can specify which one you want each project to use in the config/environment.rb file.

Alternately (or "additionally"), look in to RVM (particularly the "gemset" function) for maintaining separate gem sets for each project.

pjmorse
RVM gemsets are the way to go.
wesgarrison
+3  A: 

You still have both versions, as the other answers have mentioned. However, you don't want to call rails newapp and then change the config/environment.rb file. This will cause problems for any files that have changed between versions. Instead, create a new 2.3.5 app this way:

rails _2.3.5_ newapp

And you'll run the exact version of rails you want, to create the file structure correctly. I don't know why this isn't documented better.

Jaime Bellmyer
A: 

You can vendor the version of rails you want into your vendor/rails folder. At the command line just run rake `rake rails:freeze:edge RELEASE=2.2.2'. You don't need any version of rails installed for this to work it will take the source and build it from the remote source in your vendor directory.

rake rails:freeze:edge RELEASE=2.2.1
rake rails:freeze:edge RELEASE=2.2.2
rake rails:freeze:edge RELEASE=2.2.3
rake rails:freeze:edge RELEASE=2.2.4
rake rails:freeze:edge RELEASE=2.2.5
rake rails:freeze:edge RELEASE=2.2.6
rake rails:freeze:edge RELEASE=2.2.7
rake rails:freeze:edge RELEASE=2.2.8
Sam