Q:

How can I specify the ruby version to use on Heroku from the RVM configuration files

I'd like to use a specific version of ruby when running my app in production on Heroku.
As explained here, you only have to add a line like ruby "2.0.0" in your Gemfile.
However, as I use RVM locally, I already specified the ruby version to use in a .ruby-version file in the root directory of the project that only contains the line ruby-2.0.0-p0.
To avoid code duplication, I'd like the version to be specified in only one place, so that I'm sure that the same version is always used in development and on Heroku.
Is there a way to do that ?

A:

The Gemfile is ruby code, so you can write some ruby to read the version from .ruby-version and pass that value to the ruby method, rather than a hard-coded version string.
If the .ruby-version file is in the same directory, something like this should work:
ruby File.read(".ruby-version").strip.split("-").first

If the .ruby-version file contains "1.9.3-p327", for example, that line would be equivalent to:
ruby "1.9.3"

