The simple (if a little weird and not particularly well documented) answer is that you can pass the version number as the first parameter, surrounded by underscores like this:

rails _1.2.3_ -v
=> Rails 1.2.3
rails _2.1.0_ -v
=> Rails 2.1.0

If you specify a version that you don’t have installed you’ll get a gem activation error, like this:

/Library/Ruby/Site/1.8/rubygems.rb:636:in `report_activate_error': RubyGem version error: rails(1.2.6 not = 2.5.0) (Gem::LoadError)
	from /Library/Ruby/Site/1.8/rubygems.rb:141:in `activate'
	from /Library/Ruby/Site/1.8/rubygems.rb:49:in `gem'
	from /usr/bin/rails:18