环境 mongoid 版本 4.0.0 rails 版本 4.1.1 ruby 版本 2.1.1
起一个简单的 mongoid 项目
rails g scraffold product name
web 端 product 显示正常,使用 mongo 进行调试也正常。
奇怪的是在控制台调试的时候 比如执行 Product.all.to_a 会出现以下错误。非常奇怪,难道是 mongoid 4.0.0 版本的 bug?有其它人遇到过这种情况吗?谢谢!
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.