First thing you have to do is find out the DATABASE_URL of the app you’re interested in. Run:
heroku config –app your_app |
to get it. Then, in the other app, run this:
heroku config:add DATABASE_URL=result_of_config |
Establish an ActiveRecord connection:
db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/mydb') ActiveRecord::Base.establish_connection( :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme, :host => db.host, :username => db.user, :password => db.password, :database => db.path[1..-1], :encoding => 'utf8' ) |