我已经从Mongo_Mapper切换到Mongoid,并且出于某种原因无法部署到生产环境。我正在使用NGINX,Rails 3.1和Passenger。我不断收到此消息,“无法连接到myusernamehere:27017(Mongo :: ConnectionFailure)上的主节点”。Mongoid生产问题:无法连接到主节点
defaults: &defaults
host: localhost
# slaves:
# - host: slave1.local
# port: 27018
# - host: slave2.local
# port: 27019
development:
<<: *defaults
database: s3uploadergen_development
test:
<<: *defaults
database: s3uploadergen_test
production:
host: localhost
port: 27017
database: mydbnamehere
username: myuserhere
password: mypasswordhere
我有三重检查所有的设置,并试图ENV方法,以及(添加ENV变量production.rb并通过记录mongoid方法调用他们,但有同样的问题):
production:
host: <%= ENV['MONGOID_HOST'] %>
port: <%= ENV['MONGOID_PORT'] %>
username: <%= ENV['MONGOID_USERNAME'] %>
password: <%= ENV['MONGOID_PASSWORD'] %>
database: <%= ENV['MONGOID_DATABASE'] %>
理想情况下,我想只是在production.rb或某种初始化器中指定它。
我假设通过“记录的mongoid方法”你的意思是设置推荐的“uri”参数,而不是所有这些不同的设置? – typeoneerror
不,我认为这只适用于Heroku,我不使用。你能发布一个链接吗?或者更好的例子是? – jschorr