views:

449

answers:

4

I'd like to use Rails 2.2.2 for one project and Rails 2.3.2 for another. Both are installed.

What is rails _2.2.2_ --version supposed to do? I've read that it makes 2.2.2 the working version -- that is, the version that will be used from that point on. But when I check rails --version, I get Rails 2.3.2. So, I also want to know what rails --version tells me; is it just the latest version of Rails that I have or is it the version that will be used for rakes?

I know about RVM. Is that the best way to use different versions of Rails on different projects?

A: 

In the config/environment.rb file look for RAILS_GEM_VERSION and set the value to the required version.

RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

OR

RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
KandadaBoggu
+3  A: 

Yes "rails --version" tells which is the latest version of rails. If you want to check different versions of rails installed in your machine you have to do "gem list" which gives the list of all the gems installed in your machine with their versions.For Ex:-

rack (1.0.0)
rails (2.3.4, 2.1.1)
rake (0.8.7)

Is that the best way to use different versions of Rails on different projects?

My point of view is that No it's not a good practise to use diiferent Rails version for the different projects. but sometime you used your old projects which is of an earlier version so you have no option but install that rails version. But while creating a new application you should used the latest stable rails version.

Just for record you can used different Rails version for different projects by mentioning Rails version in enviorment.rb For Ex:-

RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION
Salil
A: 

I would try RVM gemsets for this, because it's likely that you will need to keep separate sets of dependencies for each project as well as separate versions of Rails itself.

RVM seems generally a much tidier approach - using separate environments instead of a single pool of gems means that you can easily create or destroy environments without breaking others, and it reduces the risk of making a mistake when you specify the versions of dependencies.

In the Python world people use virtualenv to create completely separate environments for each of their projects, and I think that this is a good idea to copy.

Stuart Ellis
A: 

I would use Bundler: http://gembundler.com/

It's pretty easy to get used to, and has other benefits. It's by some of the Rails core members, and I believe will become the recommended solution soon after Rails 3.0.

Jamie Cobbett