Oh just to add - remember that we're using a regular expression to find the version. If it can't find the constant we're after rails_ver will end up being nil (similar to null in most other languages).
So you may want to check before using it:
# assume old way or throw exception
# whatever you wish to do