Connect to Production Database - Explicit password on database.yml?

Hi there,

What is a good way to setup connection to production database?
Do I really need to keep production password on database.yml file? Are
there any other ways?

Thanks in advance,
Leandro

On 1 June 2015 at 19:54, Leandro França [email protected]
wrote:

Hi there,

What is a good way to setup connection to production database?
Do I really need to keep production password on database.yml file? Are there
any other ways?

In database.yml use something like
password: <%= ENV[‘MY_DATABASE_PASSWORD’] %>
and externally setup an environment variable MY_DATABASE_PASSWORD

I believe that is what
rails new …
generates automatically. Did it not for you?

Colin

It looks it did, but my app still is not connecting.
Looks like I’m missing something.

I created the database with:

rake db:create RAILS_ENV=production

But when I try to run the app, production.log gives me the error:

*PG Peer authentication failed for user “myusername” *

I’ve tried to add host:localhost to my config/database.yml, and now it
gives me this error:

PG::ConnectionBad (fe_sendauth: no password supplied

2015-06-01 16:02 GMT-03:00 Colin L. [email protected]:

On 1 June 2015 at 20:25, Leandro França [email protected]
wrote:

It looks it did, but my app still is not connecting.
Looks like I’m missing something.

Try first with the password explicitly in database.yml, then when that
is working use an environment variable instead.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs