Fix Rails version detection

Changes needed to detect Rails version in the Gemfile of Rails 4. This will not work anymore in previous version of Rails.

Need a better way to detect versions that not impact prompt performance and can deal with at least Rails 3 and 4.