关闭详细的SQL / ActiveRecord的Rails的3.1.1 [英] Turn off verbose sql/ActiveRecord for Rails 3.1.1

查看:90
本文介绍了关闭详细的SQL / ActiveRecord的Rails的3.1.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管SQL的详细功能/ ActiveRecord的要求是很有用的大部分时间,我想将其关闭的情况下,我有一些循环怎么回事。

有没有办法把它关掉?

  IRB(主):055:0> City.first
  ←[1分←[35mCity负载(1.0ms的)←[0米选择`cities`。* FROM`cities`限制1
=> #<市ID:1,名称:BLA BLA,STATE_ID:1,邮编:无,COUNTRY_ID:无,
created_at:2011-03-27十四时11分28秒,的updated_at:2011-08-16 11时14分36秒,GUID:5PK
fvvz2Gsi>
 

解决方案

在控制台:
禁用:

  old_logger =的ActiveRecord :: Base.logger
ActiveRecord的:: Base.logger =零
 

启用:

 的ActiveRecord :: Base.logger = old_logger
 

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.

Is there a way to turn it off?

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

Enable:

ActiveRecord::Base.logger = old_logger

这篇关于关闭详细的SQL / ActiveRecord的Rails的3.1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆