0

'postgres://postgres:myohmysosecret@localhost/recall'我的问题是,当部署到 Heroku DataMapper时,当我拥有DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://postgres:myohmysosecret@localhost/recall')完整的数据库连接时,它会尝试使用这部分数据库连接信息。

这是我的 Heroku 日志文件:

2012-07-08T06:49:40+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 26035`
2012-07-08T06:49:48+00:00 app[web.1]:   Is the server running on host "localhost" and accepting
2012-07-08T06:49:48+00:00 app[web.1]:   from <internal:prelude>:10:in `synchronize'
2012-07-08T06:49:48+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/data_objects-0.10.8/lib/data_objects/connection.rb:79:in `initialize': could not connect to server: Connection refused (DataObjects::ConnectionError)
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/data_objects-0.10.8/lib/data_objects/pooling.rb:177:in `block in new'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/data_objects-0.10.8/lib/data_objects/pooling.rb:172:in `new'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/data_objects-0.10.8/lib/data_objects/connection.rb:79:in `new'
2012-07-08T06:49:48+00:00 app[web.1]:   TCP/IP connections on port 5432?
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:251:in `open_connection'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/data_objects-0.10.8/lib/data_objects/connection.rb:68:in `new'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/data_objects-0.10.8/lib/data_objects/pooling.rb:119:in `new'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-transactions-1.2.0/lib/dm-transactions/adapters/dm-do-adapter.rb:69:in `open_connection'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:61:in `execute'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-postgres-adapter.rb:60:in `ensure in without_notices'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-postgres-adapter.rb:60:in `without_notices'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-postgres-adapter.rb:18:in `upgrade_model_storage'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:73:in `upgrade_model_storage'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:47:in `block in repository_execute'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:145:in `auto_upgrade!'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/descendant_set.rb:64:in `block in each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `block in each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `block in each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/ordered_set.rb:319:in `each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/subject_set.rb:210:in `each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/support/descendant_set.rb:63:in `each'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:46:in `repository_execute'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/auto_migration.rb:27:in `auto_upgrade!'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/recall.rb:25:in `<top (required)>'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/config.ru:2:in `require'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/config.ru:2:in `block in <main>'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/config.ru:1:in `new'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/config.ru:1:in `<main>'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
2012-07-08
T06:49:48+00:00 app[web.1]:     from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load'
2012-07-08T06:49:48+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>'
4

1 回答 1

3

我遇到了这个问题,最后它似乎与以下有关,这是在Heroku 教程中,但似乎是错误的:

ENV['DATABASE_URL']

基本上,您可能没有数据库。运行heroku config显示了这一点。您可以运行以下行来为您创建一个数据库,详见此处

heroku addons:add heroku-postgresql:dev

然后heroku config再次运行以获取数据库字符串,或者您可以只在 DataMapper.setup 中使用以下行:

ENV['HEROKU_POSTGRESQL_CYAN_URL']

希望这可以帮助!我已将此添加到我自己的 Heroku 支持票中,看看他们怎么说!

于 2012-12-07T20:40:21.043 回答