我在本地计算机上创建了两个用于开发的环境,并在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进行开发和分段?
答案 0 :(得分:5)
删除此行:
database: mydb_staging
因为数据库名称存在于URI中。