Ruby on rails Mongoid在rails控制台中保存记录时抛出错误

Ruby on rails Mongoid在rails控制台中保存记录时抛出错误,ruby-on-rails,mongoid,Ruby On Rails,Mongoid,我正在使用rails4.2.0。beta2mongoid 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, Mong

我正在使用rails
4.2.0。beta2
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.
.......
蒙哥德

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/Mongoid仍然存在这个问题。
原因与spring有关,一旦停用,它就可以正常工作。

Rails g mongoid:config解决了我的问题