Accessing a second database from Rails

We have a Rails app set up on Aptible, which connects to a postgres database set up by setting the DATABASE_URL.

Now we need to access a second database from within our app. The database also lives on Aptible. Locally I can access it by adding it to my database.yml, but there’s no database.yml on Aptible.

How can we set up access to another database?

Hey @ruth,

You can create multiple environment variables to store multiple database URLs. (Just use different variable names.) These can then be used in a database.yml. The Aptible platform is agnostic as to how you store your DB configuration, just so long as you read in the env variables correctly.

If I make another database URL, do I need to write my own database.yml? Right now we don’t have a database.yml file.

Hi @ruth,

That’s what I’d suggest, yes. In fact, we use the same approach for one of our internal APIs. If you have any specific questions in setting that up, let me know in a support ticket and I’d be happy to offer assistance. :thumbsup: