我正试图通过mLab连接到现有的rails console数据库。每次查询(例如GameScore.all.count、User.all.count)时,都会返回以下错误消息:
Mongo::Error::NoServerAvailable: No server is available matching preference: #<Mongo::ServerSelector::Primary:0x70240308536180 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015 from /Users/-/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mongo-2.4.1/lib/mongo/server_selector/selectable.rb:115:in `select_server'下面是如何设置我的mongoid.yml文件:
development:
clients:
default:
uri: 'mongodb://username:password@host:port/db_name'
options:
consistency: :strong
max_retries: 30
retry_interval: 1
timeout: 15会很感激你的帮助。现在真的很困惑。
发布于 2017-02-09 10:05:55
解决了。不得不降级为Rails 4.2.7和mongoid 4。
https://stackoverflow.com/questions/41937773
复制相似问题