Matt South
Matt South

Reputation: 141

configuring heroku database connection in padrino - DATABASE_URL fails

I had a problem getting a padrino (0.11.2) application to run today on heroku. The errors I was getting back suggested that the connection URL wasnt working, e.g.

2013-06-20T12:55:59.040527+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:12:in `new': +options+ should be Hash or Addressable::URI or String, but was NilClass (ArgumentError)

But I wracked my brains and couldnt see what the problem was until I read this article (https://devcenter.heroku.com/articles/config-vars) and checked my environment variables, i.e. at the console:

> heroku config
=== myapp Config Vars
HEROKU_POSTGRESQL_COBALT_URL: postgres://blah blah blah...

Noticing this I changed the DATABASE_URL constant in database.db to HEROKU_POSTGRESQL_COBALT_URL and hey presto everything worked. Are the docs out of date ? e.g.:

and something's changed or have I have messed something up somewhere? - I notice that when deploying the app, heroku automatically writes a database.yml file, but I dont think padrino will use that.

Upvotes: 1

Views: 785

Answers (1)

instanceof me
instanceof me

Reputation: 39138

You need to promote this database as you "main" one:

$ heroku pg:promote HEROKU_POSTGRESQL_COBALT_URL
Promoting HEROKU_POSTGRESQL_COBALT_URL to DATABASE_URL... done

You can then use DATABASE_URL.

Upvotes: 1

Related Questions