Here is a quick script that will install Ruby on to your Ubuntu 12.04 server

Install Ruby

Using APT

sudo apt-get install sqlite3 libsqlite3-dev rubygems
sudo gem install rails sqlite3