2014-11-03 57 views
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 
+0

Rails g mongoid:config解决了我的问题 – Murtza 2015-01-23 18:04:26

回答

2

正如信息:这仍然是使用Rails/Mongoid的当前版本的问题。 原因是有关春天,一旦停用它工作正常。