3 ms·
Access the database of a heroku application from another heroku application
- frisco 14y agoIf this is being presented as a security problem, know that this is a non-issue. This is intended behavior; Heroku config vars are considered secret. If this is just showing off that you can run multiple apps from a single database, then, yes, that too should have been clear.
- ollysb 14y agoYeah, don't really get this, it's basically saying, if you have the username, password and hostname for a database, you can access it...
- willlll 14y agoAddon providers (of which heroku postgres is) can change the the config var they set at any time. Simply copy-and-pasting creds from one app to another will leave the second app broken when those creds are changed.
- nottombrown 14y agoHeroku Postgres is now a standalone product (You can purchase postgres databases without a heroku app) so they won't change the URI for a database out from under you.
- willlll 14y agoFor the standalones we give more warning, sure. But not for the ones attached to apps.
- stretchwithme 14y agoI wrote this rails app that lets you look at the schemas of your other rails apps. Might be interesting to incorporate this into it.
- nottombrown 14y agoestablish_connection will automatically parse a postgres URI for you, so you can just use: ActiveRecord::Base.establish_connection(ENV['DATABASE_URL']) This also works for class-specific databases: class Photo < ActiveRecord::Base establish_connection(ENV['PHOTOS_DATABASE_URL']) end