未定义的方法`level`在一个Rails应用程序
问题描述:
Mongoid记录我看到的是:未定义的方法`level`在一个Rails应用程序
undefined method `level' for #<Mongoid::Logger:0xcd1a1f>
当我设置在我的init的Mongoid记录。该记录仪是由琐碎的方式设置:
Mongoid.logger = Logger.new($stdout)
在global.rb
什么是这里的问题?我如何让Mongoid登录到我自己的记录器,这样我可以看到一些疑问?
我也试着不利用:
Mongoid.logger = Logger.new($stdout, :info)
答
最新版本被打破:
https://github.com/mongoid/mongoid
http://travis-ci.org/#!/mongoid/mongoid/builds/722676
您将有等到他们修好或使用旧版本
编辑:好吧,我有同样的问题,我解决它通过这样做:
1)设置你想要mongoid宝石的特定版本在你的Gemfile
gem 'mongoid', '= 2.4.5'
2)安装
$ bundle install
3)重新启动服务器
答
我觉得这里的问题可能是你在哪里启动Mongoid.logger
,你是如何做的。在我的Rails 3.2
应用程序运行Ruby 1.9.2
与Mongoid 2.4.3
我没有任何问题实例化Mongoid Logger
。
在这里您可以阅读Mongoid Configuration,其中显示了如何设置记录器。
从我最近的应用程序的代码实例在/config
文件夹中找到在Application.rb
记录器
module Application_Name
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.mongoid.logger = Logger.new($stdout)