我有一个 Heroku 应用程序正在尝试连接到 EC2 上的 Postgres 数据库。这是我遇到的问题:
2011-05-30T23:07:48+00:00 app[web.1]: /app/.bundle/gems/ruby/1.8/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:66:in `establish_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
2011-05-30T23:07:48+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.8/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
我已按照此处描述的heroku说明进行操作在heroku应用程序上设置数据库配置。以下是其他一些可能有帮助的事情:
-
我可以使用计算机上的 psgql 管理员连接到 postgresql 数据库(表明端口转发和侦听主机已正确设置..并且不,我不允许仅我要输入的 IP - 它是通配符,以便所有 ip 都可以连接)
-
我在 EC2 上运行的 postgresql 版本是 8.4,而 Heroku 通常使用 9.0在他们的共享数据库上。这可能是问题所在吗? (我没有修复这个问题的原因是我不知道在哪里可以找到 pg_upgrade...)
提前致谢!
I've a Heroku app that is trying to connect to a Postgres DB on EC2. Here is the issue that I'm getting:
2011-05-30T23:07:48+00:00 app[web.1]: /app/.bundle/gems/ruby/1.8/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:66:in `establish_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
2011-05-30T23:07:48+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.8/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
I've followed the heroku instructions described here to set up the database configurations on the heroku app. Here are some other things that might help:
-
I can connect to the postgresql db using a psgql admin on my computer (showcasing that the port forwarding and listening to hosts is set up correctly ..and no I'm not allowing ONLY my IP to enter - its wild carded so that all ips can connect)
-
The version of postgresql that i'm running on EC2 is 8.4 while Heroku normally uses 9.0 on their shared databases. Could this be the problem? (the reason I've not fixed this is because I don't know where to find pg_upgrade...)
Thanks in advance!
发布评论
评论(2)
@amehta,不,8.4 和 9.0 不是你的问题。我天真的猜测是您的配置丢失了:
问题完全出在您的 Heroku 设置内部。尝试手动从 Heroku 连接到 EC2:
看看是否可以进一步隔离问题。
@amehta, no, 8.4 and 9.0 is not your problem. My naive guess is that your configuration is missing:
The problem is entirely local inside of your Heroku setup. Try manually connecting from Heroku to EC2:
to see if you can further isolate the problem.
问题是heroku覆盖了database.yml......所以当你调用ActiveRecord::Base.external_connection(:external_db)时,该数据库没有.yml定义
the problem is that heroku overwrites the database.yml....so when you call ActiveRecord::Base.establish_connection(:external_db) there is no .yml definition for that db