Like was said above for rails 2.3 apps in environment.rb do
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
For rails 3 you use bundler Gemfile
gem 'rails', '3.0.0'
That above would be enough but
General advise, install rvm.
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Add this to your ~/.profile.
$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
Now reload the profile so the terminal knows about rvm.
$ source .profile
Run these.
$ rvm install 1.9.2 (this installs ruby 1.9.2-p0, the latest)
$ rvm 1.9.2 --default (this sets the default implementation of ruby)
$ gem install rails
$ gem install rails -v=2.3.8
You would then be good to go, trust me if you don't use rvm you don't know what you are missing. Then as mentioned there are gemsets too look it up here http://rvm.beginrescueend.com/gemsets/