我在本地机器上创建了两个开发环境,并在 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 以进行开发和登台?