新手问题 关于 mongoid 控制台问题错误显示问题。

wcc526 · July 11, 2014 · Last by wcc526 replied at July 11, 2014 · 2495 hits

环境 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.

配置文件不对

#1 楼 @huacnlee 配置文件我采用的是默认的,直接 rails g mongoid:config,然后就没改过

#2 楼 @wcc526 潜台词:贴出来啊。

#1 楼 @huacnlee @Rei 另外,mongoid 4 为什么删掉了一些特性比如 Paranoia 和 Versioning? #2433 Mongoid::Paranoia has been removed. #2432 Mongoid::Versioning has been removed.

#4 楼 @wcc526

This should be extracted out into it's own gem and given some real love, instead of being a half-assed implementation.

https://github.com/mongoid/mongoid/issues/2432 https://github.com/mongoid/mongoid/issues/2433

#5 楼 @Rei 好的,谢谢!第一次用 mongoid。

You need to Sign in before reply, if you don't have an account, please Sign up first.