user411103
user411103

Reputation:

Rails ignoring database.yml details about my Heroku PostgreSQL DB

I have an Rails app on Heroku and, for some reason, it cannot connect to my production database when I deploy it. Seems to be ignoring anything I enter on database.yml.

This database is not an add-on on this specific Heroku app, but on a different one. However, the database connection details below are correct.

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
   adapter: postgresql
   encoding: unicode
   database: asdfasdfasdf # [HIDDEN]
   pool: 5
   host: ec2-xxx-xx-xxx-xx.compute-1.amazonaws.com
   username:  asdfasdfasdf # [HIDDEN]
   port:       5432
   password:  asdfasdfasdfasdfasdfasdf # [HIDDEN]
   timeout: 5000

Upvotes: 0

Views: 410

Answers (2)

Masudul
Masudul

Reputation: 21961

Heroku ignore the database.yml file properties. You need to set DATABASE_URL as environmental value.

ENV["DATABASE_URL"]= postgres:username:password@host/db_name

See also: Heroku postgresql configuration.

Upvotes: 2

Sanjiv
Sanjiv

Reputation: 843

Set DATABASE_URL with below command

heroku  config:addDATABASE_URL='postgres://asdfasdfasdf:[email protected]:5432/asdfasdfasdf'

Upvotes: 0

Related Questions