1
我使用軌道4.2.0.beta2
沿着mongoid 4.0.0
它在瀏覽器中正常工作,但是當我在軌道控制檯中嘗試它時,我可以實例化對象,但它不保存記錄,而是引發以下錯誤Mongoid在軌道控制檯上保存記錄時拋出錯誤
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
Rails g mongoid:config解決了我的問題 – Murtza 2015-01-23 18:04:26