Multiple Rails Versions for Multiple Projects

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

What should I do rails _2.2.2_ --version

? I read that it makes 2.2.2 the working version, which is the version to be used from now on. But when I check rails --version

, I get Rails 2.3.2

. So, I also want to know what it says rails --version

; is it just the latest version of Rails I have or is it the version that will be used for rake

s?

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

+2


a source to share


5 answers


Yes "rails --version" tells which one is the latest version of rails. If you want to check the different versions of the rails installed on your computer, you need to make a "list of gemstones" which gives a list of all the gems installed on your computer with their versions. For Ex: -

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

      

Is this the best way to use different versions of Rails for different projects?



My point is that it is not a good practice to use bilingual Rails for different projects. but sometimes you were using your old projects that are of an earlier version, so you don't have the option, but install that version of rails. But when creating a new application, you must use the latest stable rails.

Just for the record, you can use different Rails versions for different projects by specifying the Rails version in enviorment.rb For Ex: -

RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION

      

+8


a source


I would try the RVM gemset for this, because you will probably need to maintain separate sets of dependencies for each project, as well as separate Rails versions.

RVM tends to be a much cleaner approach - using separate environments instead of a single pool of gems means you can easily create or destroy environments without breaking others, and this reduces the risk of error when specifying dependency versions.



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

+1


a source


config/environment.rb

Find RAILS_GEM_VERSION

and set the value to the required version in the file .

RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

      

OR

RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

      

0


a source


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

It is fairly easy to get used to and has other benefits. These are some of the core members of Rails, and I believe this will be the recommended solution shortly after Rails 3.0.

0


a source


To answer your original question, the underscore in your version number is used to indicate the version when creating a new rails application. For example, if you need to create a new rails application, rails will use the latest version installed on your system by default, but what if you want to use the older version installed on your system? Here is the command ...

rails 2.3.4 killerapp

You will need to have rails gem 2.3.4 installed on your system! For this, you can use rvm and gemsets to group your rubies / gems into convenient packages.

I hope this helps

0


a source







All Articles