为 Rails 3.1.1 关闭详细的 sql/ActiveRecord [英] Turn off verbose sql/ActiveRecord for Rails 3.1.1
本文介绍了为 Rails 3.1.1 关闭详细的 sql/ActiveRecord的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
虽然 SQL/ActiveRecord 调用的详细功能在大多数情况下很有用,但我想在我有一些循环的情况下将其关闭.
Whereas the verbose feature of SQL/ActiveRecord calls is useful most of the time, I would like to turn it off in cases where I have some looping going on.
有没有办法关闭它?
irb(main):055:0> City.first
←[1m←[35mCity Load (1.0ms)←[0m SELECT `cities`.* FROM `cities` LIMIT 1
=> #<City id: 1, name: "bla bla", state_id: 1, zip: nil, country_id: nil,
created_at: "2011-03-27 14:11:28", updated_at: "2011-08-16 11:14:36", guid: "5PK
fvvz2Gsi">
推荐答案
在控制台中:
禁用:
In console:
Disable:
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
启用:
ActiveRecord::Base.logger = old_logger
这篇关于为 Rails 3.1.1 关闭详细的 sql/ActiveRecord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文