UPDATE 2012年6月9日:Heroku的mongohq和mongoid蒙戈:: ConnectionFailure
设置与Heroku的mongoid 3.0.0.rc,看到这个要点:https://gist.github.com/2900804
UPDATE 2011年1月22日:
乌里现在可以优先mongoid.yml
https://github.com/mongoid/mongoid/issues/issue/266
UPDATE 2010年8月12日:虽然我得到一个公认的答案5月6日来自Jackues Crocker,这个问题的一些方面很容易搞砸!它又发生在我身上,我决定研究mongoid源代码。所以,这里有云:
目前,主机:端口:名称/数据库:设置优先于URI:设置。因此,非常不提供信息的错误消息,由于发生在请求本地主机: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'] %>
与任一去除主机修复它*默认
ORIGINAL问:
我已经添加了mongoHQ插件为mongodb at heroku。它与崩溃:
connect_to_master': failed to connect to any given host:port (Mongo::ConnectionFailure)
的描述在线(heroku mongohq)更针对mongomapper,因为我看到它。我正在运行ruby 1.9.1并使用mongoid来引导rails 3-beta。
我的感觉说有ENV['MONGOHQ_URL']
,它说MongoHQ插件设置,但我没有在我的应用程序的任何地方设置MONGOHQ_URL
。我想这个问题在我的 mongoid.yml中?
defaults: &defaults
host: localhost
development:
<<: *defaults
database: aliado_development
test:
<<: *defaults
database: aliado_test
# set these environment variables on your prod server
production:
<<: *defaults
host: <%= ENV['MONGOID_HOST'] %>
port: <%= ENV['MONGOID_PORT'] %>
username: <%= ENV['MONGOID_USERNAME'] %>
password: <%= ENV['MONGOID_PASSWORD'] %>
database: <%= ENV['MONGOID_DATABASE'] %>
它工作正常,在当地,但在Heroku的失败,更多的堆栈跟踪:
==> crashlog.log <==
Cannot write to outdated .bundle/environment.rb to update it
/disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/rack-1.1.0/lib/rack.rb:14: warning: already initialized constant VERSION
/disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongo-0.20.1/lib/mongo/connection.rb:435:in `connect_to_master': failed to connect to any given host:port (Mongo::ConnectionFailure)
from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongo-0.20.1/lib/mongo/connection.rb:112:in `initialize'
from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4
/lib/mongoid/railtie.rb:32:in `new'
from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4/lib/mongoid/railtie.rb:32:in `block (2 levels) in <class:Railtie>'
from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4/lib/mongoid.rb:110:in `configure'
from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/mongoid-2.0.0.beta4/lib/mongoid/railtie.rb:21:in `block in <class:Railtie>'
from /disk1/home/slugs/176479_b14df52_b875/mnt/.bundle/gems/gems/railties-3.0.0.beta3/lib/rails/initializable.rb:25:in `instance_exec'
.....
它所有的工作在当地,这两个测试和应用。我没有想法...有什么建议吗?
PS:有高repu心的人创建标签'mongohq'?
的URI修复不似乎仍然有效。我在github.com/durran/mongoid发现了票据/问题,并在http://ragingonrails.com/post/566548996/using-mongoid-on-heroku-with-mongohq上找到了它的来源。我以同样的方式做了它,操纵端口,主机等的ENV。这工作! – oma 2010-05-07 10:19:55
此答案标记为正确。对于其他人来说,请注意,我必须自己琐事。它也应该是':git => git:// github.com/durran/mongoid.git' – oma 2010-05-07 14:17:44
现在需要使用'production> sessions> default> uri' - 更新匹配的答案。 – chrismdp 2012-09-21 09:31:11