How to get files .gitignore'd on heroku?

heroku, ruby-on-rails

Solution

Heroku stores config variables to the ENV environment

heroku config will display these list of variables

heroku config:get DATABASE_URL --app YOUR_APP

Will return the database url that Heroku as assigned to your app, using this string one can deduce the parameters necessary to connect to your heroku applications database, it follows this format

username:password@database_ip:port/database_name

This should provide you with all the values you'll need for the heroku side database.yml, its a file that is created for you each time you deploy and there is nothing it that can't be gotten from the above URL.

gitignoring the database.yml file is good practice

Problem

We have inherited a Rails project hosted on Heroku. The problem is that I don't understand how to get a copy of the database.yml or other various config files that have been ignored in the .gitignore file. Sure I can look through the history but it seems like a hip shot when comparing it to what should be on the production server. Right now we are having to make changes to the staging environment which makes things a bit arduous and less efficient than having a local dev environment so we can really get under the hood. Obviously, having an exact copy of the config is a good place to start. With other hosts it's easy to get access to all the files on the server using good ol' ftp. This might be more easily addressed with some sort of git procedure that I am less familiar with.

Original source