Ruby is not installed on Ubuntu out of the box. To get Rails working you will need to install ruby and some other things first. Simply enter following line on shell prompt
sudo apt-get install ruby ruby1.8-dev irb rubygems build-essential libopenssl-ruby
This will install ruby and ruby gems on your machine. To install rails enter following on shell prompt
sudo gem install rails rake mongrel
this will install rails and mongrel, a rails web server, on your system. If you dont need mongrel you can remove mongrel from the above line.