Reputation: 151196
On Ubuntu, if Rails 3.0 was installed using
sudo gem install rails
and then Rails 2.3.8 was installed later:
sudo gem install -v 2.3.8 rails
Now the system has both Rails 2.3.8 and 3.0.0. But if the following is typed into bash:
rails -v
Then 3.0.0 will show. Is there a way to switch to using 2.3.8 instead?
Upvotes: 1
Views: 400
Reputation: 2913
Like was said above for rails 2.3 apps in environment.rb do
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
For rails 3 you use bundler Gemfile
gem 'rails', '3.0.0'
That above would be enough but
General advise, install rvm.
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Add this to your ~/.profile.
$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
Now reload the profile so the terminal knows about rvm.
$ source .profile
Run these.
$ rvm install 1.9.2 (this installs ruby 1.9.2-p0, the latest)
$ rvm 1.9.2 --default (this sets the default implementation of ruby)
$ gem install rails
$ gem install rails -v=2.3.8
You would then be good to go, trust me if you don't use rvm you don't know what you are missing. Then as mentioned there are gemsets too look it up here http://rvm.beginrescueend.com/gemsets/
Upvotes: 2
Reputation: 151196
I also found a way in the Agile book:
rails _2.3.8_ -v
and it will say it is version 2.3.8, although I don't know how well this approach works (how well it isolates the 2 versions of Rails) comparing to using RVM.
Upvotes: 0
Reputation: 9964
I recommend to have a look at the RVM tool and especially its gemsets feature.
Upvotes: 3
Reputation: 68016
Put this in your environment.rb
file
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
If you're talking about launching rails executable from shell, then just specify correct path. Once 2.3.8 executable is launched, I don't think it can somehow find and transfer control to 3.0.0 executable.
Upvotes: 1