Why would you not just access ENV['DATABASE_URL']
and break it up into the constituent parts? To see how this is done, if you do heroku run bash
and do cat config\database.yml
you will see how Heroku does this itself.
To ensure that locally it works as well if you execute via foreman run <Scriptname>
then it will be executed and the contents of your .env will be loaded.