Connection with the database with figaro is not working on rails

696 views Asked by At

I am using rails with figaro for configuration, database user with the name test. I have a DATABASE_URL in application.yml

DATABASE_URL: "postgresql://localhost/database_name?user=test"

When I run a

rake db:migrate

I get the following error

PG::ConnectionBad: fe_sendauth: no password supplied
2

There are 2 answers

0
random-forest-cat On

Check config/database.yml to ensure your password is wired up for postgresql adapter.

it should look something like this:

default:
  adapter: postgresql
  database: foo
  user: bar
  password: <%= ENV['pg_password'] %>

pg_password should be defined in your figaro config, where it becomes accessible as an environment variable.

0
Franck BERNERON On

I just want to emphasize you call the Figaro ENV variables in your .yml using the ERB Syntax :

 username: <%= ENV["PG_USERNAME"] %>
  password: <%= ENV["PG_PASSWORD"] %>

Hope this helps...!