Follow:
sudo apt-get update
sudo apt-get install build-essential git-core curl libmysqlclient16-dev nodejs
Now let’s install the latest version of RVM using curl:
sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
umask g+w
source /etc/profile.d/rvm.sh
Now you'll need to ask RVM if it needs any more programs and if so you'll need to install them to do this type:
rvm requirements
Two things could happen here if you see the following message saying you need to install 'rvm', ignore this it and restart your terminal, this should fix the problem.
The program 'rvm' is currently not installed. You can install it by typing:
sudo apt-get install ruby-rvm
You should see something that looks like this
after you restart your terminal:

This tells you which packages you need to install using apt-get, just copy and paste the apt-get section under "# ForRuby" and run using the sudo command, this should look something like this:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
Now you just need to give the user account access to the rvm files, you do this with the following command substituting [user] for the user you wish to use
sudo chown -R [user]:[user] /usr/local/rvm
Once you have installed all these packages its time to install
Ruby 1.9.2 herself. The following command will install
Ruby 1.9.2 using the
rmv package. However this can take a few minutes
(15 in my case) to install so I recommend getting a drink, or my favourite, a pizza

.
rvm install 1.9.2
Once ruby is installed you should set Ruby 1.9.2 as your default Ruby version, to do this enter:
source "/usr/local/rvm/scripts/rvm"
rvm --default use 1.9.2
You can test that Ruby is installed correctly and running at version 1.9.2 by typing
ruby -v
The nice thing about RVM is you can use it to install any version of Ruby and switch between the versions your have installed, to do this just enter "rvm install [Version Number]" then "rvm --default use [Version Number", you can then use "rvm --default use" to change to any installed version.This should output something like "ruby 1.9.2p290.." showing you that version 1.9.2p290 is installed and is now the defaultRuby version.
Now that you have the latest version of ruby installed I’m sure you want to get the latest version of Rails installed, at the time of writing this tutorial that’s Rails 3.1. To installRails we can use GEM which is installed along with RVM and Ruby, to install the latest version of Rails just type, (this can take also take a while):
gem install rails
And that’s it you have now installed RVM, Ruby 1.9.2 and Rails 3.1 on Ubuntu 11.10 configured to use sqlite3, you can now setup your new Rails package with
rails new [project name]
Just as a final note, If you want to use MySQL instead of sqlite3 you’ll need to enter the following
sudo apt-get install mysql-server
gem install mysql2
rails new [project name] -d mysql