Rails gem version relationship to AR gem versions

I have several versions of Rails on my box.

How does a given version of Rails know which version of the ActiveRecord gem to use? For example, how does Rails 1.2.6 load AR version 1.15.6?

Thanks, Wes