I was trying to install redmine from the link:

Got this problem:

gem install -v=2.3.5 rails
ERROR:  could not find gem rails locally or in a repository

This fixed:

wget http://rubyforge.org/frs/download.php/74343/rubygems-1.5.3.tgz
tar -xf rubygems*tgz
cd rubygems*
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem