Environment Variables or YAML config files

In my experience, environment variables are the configuration option of last-resort. They absolutely have their place, but applications should generally check some other more reliable and explicitly intentional configuration option first. I would highly recommend loading configuration from a YAML file and only use an environment variable as a fallback. Always assume that your environment variable is going to apply to everything system-wide and assume that it's going to accidentally get unset or set to the wrong value at some point. i.e., your app shouldn't commit seppuku because some configuration directory got set to / and it doesn't have permissions to it (or worse you wipe your drive because the app ran as root). Or more likely, something like your RAILS_ENV was set to test when it should've been production and no one realized and now users are writing data to the wrong place or to /dev/null on account of all the 500s.

Personally, I like to drop logger.warn messages anytime I fallback to an environment variable for a configuration value.

With your precise issue, honestly, I'd probably pass in the configuration value for which environment to start on the command line.