Allow Rails to load without Rubygems loaded

Rails is a great gem citizen, and doesn't explicitly require Rubygems anywhere. However, while working on a Rails app that doesn't require Rubygems before loading Rails, we've noticed a few places where Rails expects Rubygems to be loaded even though it doesn't require it.

This pull request simply checks for Rubygems before calling Rubygems methods, so that Rails works without Rubygems already being loaded.
This defeats the purpose of having this.