Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access rails 2.3.x commands when rails 3 is installed?

I'd like to play around with rails 3, but I'm still used to rails 2.3.8 so I have them both installed. Wanting to make a quick rails app to demonstrate how a plugin works, I want to run the command rails test_app but since I have rails 3 installed, I have to run rails new test_app but that will generate a rails 3 app. Is there a way around this while having rails 3 installed?

like image 823
aarona Avatar asked Feb 27 '23 07:02

aarona


1 Answers

This is a perfect example of what rvm's gemsets can do for you.

In a nutshell (after installing rvm):

% rvm gemset create rails2
% rvm gemset use rails2
% gem install rails -v=2.3.8

Now your current rails is Rails 2!

Whenever you wish to use Rails 2 instead of Rails 3, do:

% rvm gemset use rails2

This will remain in effect for the current terminal/shell session. You can also switch back:

% rvm default

Of course you can also do the exact opposite and create a rails3 gemset to play around with Rails 3, and leave Rails 2 installed as the default.

(Apart from having gemsets, rvm lets you install multiple versions of Ruby on the same system, allowing you to switch between different versions with a simple rvm 1.9.2 or rvm 1.8.7.)

like image 183
molf Avatar answered Mar 27 '23 13:03

molf