更新2012年6月9日:
在heroku上使用mongoid 3.0.0.rc进行设置,请参阅此要点:https://gist.github.com/2900804
2011年1月22日更新:
Uri现在优先于mongoid.yml
https://github.com/mongoid/mongoid/issues/issue/266
更新2010年8月12日:虽然我得到了Jackues Crocker的第6个可接受的答案,但是这个问题的某些方面让人很容易搞砸!它再次发生在我身上,我决定研究mongoid源代码.所以,在这里:
目前,主机:端口:名称/数据库:设置超过uri:设置.因此,由于对localhost:xxxx的请求而不是对flame.local.mongohq.com:xxxx的请求,发生了非常无法提供信息的错误消息
这会打破!
defaults: &defaults
host: localhost <- THIS 'OVERWRITES' host in the uri!
production:
<<: *defaults <- BE CAREFUL WITH WHAT YOU BRING IN. THE host: FROM DEFAULTS WILL BE THE ONE APPLIED, not your uri host.
uri: <%= ENV['MONGOHQ_URL'] %>
Run Code Online (Sandbox Code Playgroud)
修复它,删除主机:默认情况下,和/或删除<<:*默认值
原文问:
我已经在heroku为mongodb添加了mongoHQ插件.它崩溃了:
connect_to_master': failed to connect to any given host:port …Run Code Online (Sandbox Code Playgroud)