views:

55

answers:

2

I have both Rails 2.3.4 and Rails 3.0.0.beta installed on my local machine. I am using ActiveRecord in a stand alone ruby script and when I do require 'active_record' 3.0.0.beta is loaded. How can I force it to require 2.3.4 instead? (without uninstalling 3.0.0.beta)

+6  A: 

This is covered in the RubyGems manual @ http://docs.rubygems.org/read/chapter/4

do:

require 'rubygems'
gem 'activerecord', '= 2.3.4'
Lee
A: 

A little trick is require 'activerecord' when you want 2.3.5 and 'active_record' when you want 3.0.0.beta.

You have a warning when you using activerecord require but it's load only 2.3.5.

After if you want manage several gem in same computer, you can try rvm and gemset system. It's really great.

shingara
Works great. Thank you!
magnushjelm
This is definitely a hacky way to do it. The "right" way to do it is covered in the answer by Lee...
severin
but need Rubygems. fix rubygems like that is not a good way too in all the time.
shingara