连接 Heroku <-> 时发生异常 ActiveRecord::AdapterNotSpecified Postgres (EC2)

发布于 2024-11-10 17:09:00 字数 989 浏览 0 评论 0 原文

我有一个 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应用程序上设置数据库配置。以下是其他一些可能有帮助的事情:

  1. 我可以使用计算机上的 psgql 管理员连接到 postgresql 数据库(表明端口转发和侦听主机已正确设置..并且不,我不允许仅我要输入的 IP - 它是通配符,以便所有 ip 都可以连接)

  2. 我在 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:

  1. 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)

  2. 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心的位置 2024-11-17 17:09:00

@amehta,不,8.4 和 9.0 不是你的问题。我天真的猜测是您的配置丢失了:

adapter: postgresql

问题完全出在您的 Heroku 设置内部。尝试手动从 Heroku 连接到 EC2:

require 'postgres'
conn = PGconn.connect('amazone-host', 5432, '', '', 'dbname', 'username', 'pass')
puts conn.exec('SELECT version()')[0]

看看是否可以进一步隔离问题。

@amehta, no, 8.4 and 9.0 is not your problem. My naive guess is that your configuration is missing:

adapter: postgresql

The problem is entirely local inside of your Heroku setup. Try manually connecting from Heroku to EC2:

require 'postgres'
conn = PGconn.connect('amazone-host', 5432, '', '', 'dbname', 'username', 'pass')
puts conn.exec('SELECT version()')[0]

to see if you can further isolate the problem.

挽袖吟 2024-11-17 17:09:00

问题是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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文