【问题标题】:How to configure mongoid for development and staging environments properly?如何为开发和登台环境正确配置 mongoid?
【发布时间】:2012-12-25 13:47:26
【问题描述】:

我已经创建了两个环境用于本地机器上的开发和 Heroku 上的暂存。

这是我的“mongoid.yml”:

development:
  sessions:
    default:
      database: mydb_development
      hosts:
        - localhost:27017
staging:
  sessions:
    default:
      database: mydb_staging
      uri: <%= ENV['MONGOLAB_URI'] %>

Mongoid 在本地机器上正常工作,但是在部署 heroku 之后我出现下一个错误:

/app/vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.14/lib/mongoid/config/validators/session.rb:81:in `validate_session_uri':  (Mongoid::Errors::MixedSessionConfiguration)
2012-12-25T10:12:44+00:00 app[web.1]: Problem:
2012-12-25T10:12:44+00:00 app[web.1]:   Both uri and standard configuration options defined for session: 'default'.
2012-12-25T10:12:44+00:00 app[web.1]: Summary:
2012-12-25T10:12:44+00:00 app[web.1]:   Instead of simply giving uri or standard options a preference order, Mongoid assumes that you have made a mistake in your configuration and requires that you provide one or the other, but not both. The options that were provided were: {"database"=>"xxxxx_staging", "uri"=>"mongodb://xxxxx:xxxxx@xxxxx.mongolab.com:37587/xxxxxx"}.
2012-12-25T10:12:44+00:00 app[web.1]: Resolution:
2012-12-25T10:12:44+00:00 app[web.1]:   Provide either only a uri as configuration or only standard options.

“仅提供 uri 作为配置或仅提供标准选项”是什么意思? 如何正确配置 mongoid 以进行开发和暂存?

【问题讨论】:

    标签: ruby-on-rails ruby heroku mongoid


    【解决方案1】:

    删除这一行:

    database: mydb_staging
    

    因为数据库名称存在于 URI 中。

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 2016-02-27
      • 1970-01-01
      • 2015-07-15
      • 2019-10-30
      • 1970-01-01
      • 2019-11-22
      • 2018-09-07
      • 2020-05-05
      相关资源
      最近更新 更多