Mac OS X Yosemite comes included with Ruby 2.0. But when you are working with the latest version of Rails[4.2], you might be in need of the latest version of Ruby [2.2] to have better performance. So, how do you update Ruby? There is a simple solution for this is to use Ruby Version Manager (RVM), which is a standard for upgrading ruby on OSX.
To do this. Open your terminal and run
\curl -L https://get.rvm.io | bash -s stable –ruby
When this is complete, you need to restart your terminal for the rvm to work.
Now, run rvm list known
This shows the list of versions of the ruby.
Now, run rvm install ruby-2.2.0
If you type ruby -v in the terminal, it still shows you ruby 2.0.
To use the latest installed version. Run rvm use ruby-2.2.0
Now, when you look at the version, it shows you the following:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
There you go, you have the latest version of ruby now in use.