开发者

If I have both Rails 2.3.8 and 3.0.0 (as gems), can I switch between them easily?

On Ubuntu, if Rails 3.0 was installed us开发者_如何转开发ing

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?


I recommend to have a look at the RVM tool and especially its gemsets feature.


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/


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜