

Access the database of a heroku application from another heroku application - geoscripting
http://debugarea.com/2013/03/30/access-the-database-of-a-heroku-application-from-another-heroku-application/

======
willlll
Addon 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
Heroku 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
For the standalones we give more warning, sure. But not for the ones attached
to apps.

------
nottombrown
establish_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

------
frisco
If 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
Yeah, don't really get this, it's basically saying, if you have the username,
password and hostname for a database, you can access it...

------
stretchwithme
I wrote this rails app that lets you look at the schemas of your other rails
apps. Might be interesting to incorporate this into it.

