问题
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.:
- https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-ruby
- http://www.padrinorb.com/guides/blog-tutorial
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.
回答1:
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
.
来源:https://stackoverflow.com/questions/17218592/configuring-heroku-database-connection-in-padrino-database-url-fails