Mongoid 3 + Heroku (MongoHQ) cause Moped::Errors::OperationFailure

China☆狼群 提交于 2019-12-02 17:03:24

You will need to use Ruby 1.9.3. See Mongoid documentation here and Heroku documentation here on how to use 1.9.3.

I was also getting similar errors, and I changed my gemfile to include ruby '1.9.3' and everything worked as expected again.

Edit: @herb pointed out that you need the latest version of bundler for this to work (gem install bundler --pre). Otherwise, ruby '1.9.3' in your Gemfile will not work.

Try adding an "options" area to the default session and add "skip_version_check: true" as one of the options.

Jason MongoHQ

As a workaround, hardcoding the uri from heroku config seems to do the trick.

ex:

production:
  sessions:
    default:
      uri: "mongodb://heroku:xxxx@domain.mongohq.com:000/appyyyy"
      options:
        skip_version_check: true
        safe: true

I'm guessing the nilclass error was because <%= ENV['MONGOHQ_URL'] %> was returning nil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!