Mongoid:(复制)配置文件 yml 未加载
development:
hosts: [[database_1.mongolab.com, 12345], [database_2.mongolab.com, 12345]]
database: database_name
username: database_user
password: database_pass
persist_in_safe_mode: true
raise_not_found_error: false
使用以下命令加载此配置文件(config/mongoid.yml):
Mongoid.load!("config/mongoid.yml")
但我收到此错误:
Mongo::ConnectionFailure at /
Failed to connect to a master node at localhost:27017
development:
hosts: [[database_1.mongolab.com, 12345], [database_2.mongolab.com, 12345]]
database: database_name
username: database_user
password: database_pass
persist_in_safe_mode: true
raise_not_found_error: false
This configuration file (config/mongoid.yml) is loaded using :
Mongoid.load!("config/mongoid.yml")
But I get this error :
Mongo::ConnectionFailure at /
Failed to connect to a master node at localhost:27017
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建您的 mongoid.yml 并将其放置在您喜欢的任何地方。但请确保在应用程序路径
(config/initialization)
下执行以下操作:更新
要在项目中使用 mongoid master,请在 Gemfile 中进行设置
You can create your mongoid.yml and place it anywhere you like. But be sure that on application path
(config/initialization)
under that you do the following:Update
To use mongoid master in your project, set this in your Gemfile
将 Mongoid 与 Rails 结合使用时,您正在使用 Sinatra 配置方案。
试试这个:
You are using the Sinatra configuration scheme when using Mongoid with Rails.
Try this: