Ruby Version Manager (http://rvm.beginrescueend.com/) is a great tools for you to manage multiple versions of ruby and gems. If you have two projects, one is using ruby 1.8.7 and rails 2.2.2 and the other one using ruby 1.9.2 and rails 3, if you upgrade your ruby to 1.9.2 and rails to 3, you are going to have problem with first project. So the correct way is to use rvm. Here is how you can install rvm and rails 3 on mac.
1. open terminal, and type the following:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
What this does is that it download the shell script rvm-install-head.sh using curl command and execute it with bash. If you copy http://rvm.beginrescueend.com/releases/rvm-install-head to browser, it actually downloads the shell script. If you are interested in what this script does, you can download it and look at the script.
2. install the rvm command
Now rvm is downloaded and installed in your computer, but if you type rvm in terminal, it doesn't recognize as a command. So here is what you should do. Go to ~/.bash_profile file and paste the following line at the end of the file
# This loads RVM into a shell session. [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
However, in my case, i didn't find the ~/.bash_profile file. So i have to create it myself and put the line above inside the file. Now you are ready to use rvm. Create the ~/.bash_profile with the following code:
Note that if you are using zsh as default shell instead of using bash. Then you have to add the above codes to ~/.zprofile. Create that file if not present. If there is a need for you to use bash instead of zsh, you can use chsh command to change the default shell:
#This change the default shell to use bash. chsh -s /bin/bash
# This change the default shell to zsh. chsh -s /bin/zsh
Try the following to get a feel how rvm works.
1. Install ruby 1.8.7
rvm install 1.8.7
2. Install ruby 1.9.2 with rvm.
rvm install 1.9.2
3. Display ruby version
It should still show 1.8.7.
4. Switch to use ruby 1.9.2
rvm use 1.9.2
Now if you run ruby -v, it should show 1.9.2
5. Install rails 3
With ruby 1.9.2, now you can install rails
gem install rails
For your information, the replacement for RVM on windows is PIK.https://github.com/vertiginous/pik