Rahul
Rahul

Reputation: 47146

Can I use different versions of rails in the same machine?

I am currently analyzing two rails project one of them is in version 2.3.5 and the other one is in version 2.3.4. How can I run both the projects in the same machine?

Upvotes: 1

Views: 410

Answers (3)

Richard Calahan
Richard Calahan

Reputation: 166

I use Ruby Version Manager (RVM), http://beginrescueend.com/.

It lets you install multiple ruby environments in your home directory. You can also create multiple 'gemsets' specific to each of your 'rubies'.

Now all of your gems, Rails especially, can exist in their own safe environments. You simply switch between each of them. Very very very awesome.

EDIT

It appears in your comment to your question that you're using windows...so looks like RVM won't work. The RVM site recommends PIK: http://github.com/vertiginous/pik as a windows alternative.

Upvotes: 5

fl00r
fl00r

Reputation: 83680

You can specify which version do you want to use in your project in your config/environment.rb file:

RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION

Or pass it straight:

ruby script/console RAILS_GEM_VERSION='2.3.5'

So you can run both of them:

# on http://localhost:3000
ruby script/console RAILS_GEM_VERSION='2.3.4' -p 3000
# on http://localhost:3001
ruby script/console RAILS_GEM_VERSION='2.3.5' -p 3001

Upvotes: 0

apneadiving
apneadiving

Reputation: 115541

It's just a question of gems. Bundler handles this for you so there should't be any difficulty.

Detail your question if you face a stumbling block.

Upvotes: 3

Related Questions