Mitchell
Mitchell

Reputation: 313

How to get files .gitignore'd on heroku?

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.

Upvotes: 4

Views: 1072

Answers (2)

TheIrishGuy
TheIrishGuy

Reputation: 2573

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

Upvotes: 4

John Beynon
John Beynon

Reputation: 37507

It's not something you can do - entries added to .gitignore means they've been excluded from source control. They've never made it into Git.

As for database.yml you can just create the file in app\config\database.yml with local settings, it should look something like;

development:
  adapter: postgresql
  host: 127.0.0.1
  username: somelocaluser
  database: somelocaldb

It's safe to say though, that if the file is not in Git then it's not on Heroku since that's the only way you can get files to Heroku. Any config is likely to be in environment variables - heroku config will show you that.

Upvotes: 2

Related Questions