To install:
sudo gem install rails --source http://gems.rubyonrails.org
Then change environment.rb like so:
RAILS_GEM_VERSION = '>= 1.99' unless defined? RAILS_GEM_VERSION
if you get an error when running script/server that is something like:
Missing the Rails 1.99.0 gem. Please `gem install -v=1.99.0 rails`
then update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.