我在4.2.0.beta2
使用rails mongoid 4.0.0
它在浏览器中工作正常但是当我在rails控制台中尝试它时,我可以实例化对象,但它不会保存记录而不是它抛出错误
Mongoid::Errors::NoSessionConfig:
Problem:
No configuration could be found for a session named 'default'.
Summary:
When attempting to create the new session, Mongoid could not find a session configuration for the name: 'default'. This is necessary in order to know the host, port, and options needed to connect.
Resolution:
Double check your mongoid.yml to make sure under the sessions key that a configuration exists for 'default'. If you have set the configuration programatically, ensure that 'default' exists in the configuration hash.
.......
mongoid.yml
development:
sessions:
default:
database: okaab_development
hosts:
- localhost:27017
options:
options:
test:
sessions:
default:
database: okaab_test
hosts:
- localhost:27017
options:
read: primary
max_retries: 1
retry_interval: 0
答案 0 :(得分:2)
就像信息:这仍然是当前版本的Rails / Mongoid的一个问题。 原因与春天有关,一旦停用它就可以正常工作。