Getting your first ruby on rails stack up and running can be a bit of a chore, here's a quick guide on how to do it on a linux box but the instructions should be equally good for OS X users.
Now depending on your OS, you've got a few options on how to get ruby up and running. The easiest way is to use the built-in package management system. This will give you the latest known stable version of ruby for your environment, and hopefully reduce or remove any potential conflicts with other installed software. The downside is that quite often the packaged version are a few releases behind the currently advertised stable version just due to the time it takes for the linux distribution manages to bundle them up.
If you've got a package manager, just enter whichever of the following commands is the most appropriate:
sudo yum install ruby irb rdoc ruby-devel
sudo apt-get ruby irb rdoc ruby-devel
If you've decided to take the from source option, then you'll need to do the following:
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
tar zxvf ruby-1.8.7-p72.tar.gz
cd ruby-1.8.7-p72
./configure
make
sudo make install
Gem is the package system for ruby, and it's the easiest way to install most of your ruby dependencies (including rails). So grab it from sourceforge:
wget http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz
tar zxvf rubygems-1.3.0.tgz
cd rubygems-1.3.0
sudo ruby ./setup.rb
Now getting rails installed is a breeze, all you need to do is:
sudo gem install rails
You may need to install your native database driver bindings too, if so:
sudo gem install mysql
sudo gem install postgres