简体   繁体   中英

Can we install two different versions of ruby and map them to respective versions of rails on the same server?

I have already installed Ruby 1.8.7 and Rails 2.3.8 which is working fine.

Now, I need to install Rails 3.2.8 in order to install a gem and my goal build the same compatible with Rails 2.3.8 based on how it is developed.

I tried installing Rails 3.2.8 using gem install rails -v=3.2.8 -include-dependencies

but to my surprise when I checked gem list rails , it shows only Rails 2.3.8 and I'm unable to create a new app using rails 3.2.8 test .

I'm not sure but I read that Rails > 3.0 doesn't work well with Ruby 1.8.7 and needs Ruby>1.9

Rails 3.2 is compatible with Ruby 1.8.7. What you could do is have a ruby version manager like RVM or Rbenv. I use RVM but some people prefer Rbenv as it does not mess with your shell.

Using version managers will allow you to have different versions of ruby and with RVM you can create different gemsets for each specific version.

EDIT Here's the link for the release notes for rails 3.2 http://guides.rubyonrails.org/3_2_release_notes.html

EDIT

There's a couple of commands that you can use.

rvm list

will list the versions of ruby you have installed.

To install a version of ruby you'd do something like rvm install 1.9.3 to use that version you'd do something like rvm use 1.9.3 You can even specify patch levels and switch between different versions.

Now, rvm uses a concept of gemsets, to create a gemset you can set up an .rvmrc file in your project with the following command

rvm --create ruby-1.9.3-p286@some-project

it will create a set of gems called some-project where you can install whatever gem versions you want.

Notice that command can be ran from the command line as well. That will separate all the gems per project and you can switch between gemsets as you would ruby versions. Then in whichever gemset you'd just run gem install rails and the version

Your ruby version is good enough for both rails 2 & 3.

Try to create new app like below:

rails _3.2.8_ new appname

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM