Ruby on Rails
HowtoLockToSpecificRailsVersions

It is possible to lock your app to a specific set of library versions.

Use the GEM_RAILS_VERSION constant

Add the following line to your environment.rb file before the boot file is loaded, at the very top. Not sure when support for that was added. The space around the equals is required, so are the single quotes, not double.

RAILS_GEM_VERSION = '1.2.6'

Tie to Rails 0.9.5

Go to config/environment.rb where you can tie Rails to specific versions like this:

require_gem 'activerecord', '= 1.6.0'
require_gem 'actionpack', '= 1.4.0'
require_gem 'actionmailer', '= 0.6.1'
require_gem 'rails', '= 0.9.5'

Update (for Rails 0.12.1)

This is the code that I have in my config/environment.rb. The only lines it replaces are the same that are found in the if conditional

use_latest = true

if use_latest
  require 'active_support'
  require 'active_record'
  require 'action_controller'
  require 'action_mailer'
  require 'action_web_service'
else
  require_gem 'activesupport', '<= 1.0.4'
  require_gem 'actionwebservice', '<= 0.7.1'
  require_gem 'activerecord', '<= 1.10.1'
  require_gem 'actionpack', '<= 1.8.1'
  require_gem 'actionmailer', '<= 0.9.1'
  require_gem 'rails', '<= 0.12.1'
end

Update (for Rails 0.13.1)

This code is the same as above but for 0.13.1

# Set use_latest=true for latest gem install
# otherwise use 0.13.1 version of Rails
use_latest = false

if use_latest
  require 'active_support'
  require 'active_record'
  require 'action_controller'
  require 'action_mailer'
  require 'action_web_service'
else
  require_gem 'activesupport', '= 1.1.1'
  require_gem 'actionwebservice', '= 0.8.1'
  require_gem 'activerecord', '= 1.11.1'
  require_gem 'actionpack', '= 1.9.1'
  require_gem 'actionmailer', '= 1.0.1'
  require_gem 'rails', '= 0.13.1'
end

Update (for Rails 1.0.0)

This code is the same as above but for 1.0.0

# Set use_latest=true for latest gem install
# otherwise use 1.0.0 version of Rails
# only need to include rails gem, rest are implied
use_latest = false

if use_latest
  require 'active_support'
  require 'active_record'
  require 'action_controller'
  require 'action_mailer'
  require 'action_web_service'
else
  require_gem 'rails', '<= 1.0.0'
end

Rails gem version table:

rails 0.9.5 0.12.1 0.13.1 1.0.0 1.1.0 1.2.1 1.2.3
activerecord 1.6.0 1.10.1 1.11.1 1.13.2 1.14.0 1.15.1 1.15.3
actionpack 1.4.0 1.8.1 1.9.1 1.11.2 1.12.0 1.13.1 1.13.3
actionmailer 0.6.1 0.9.1 1.0.1 1.1.5 1.2.0 1.3.1 1.3.3
activesupport X 1.0.4 1.1.1 1.2.5 1.3.0 1.4.0 1.4.2
actionwebservice X 0.7.1 0.8.1 1.0.0 1.1.0 1.2.1 1.2.3

How would you find out what version all the dependencies were in for a specific Rails release?

This very question is addressed in the gem manual with Rails being used for the example.