Rails的ActiveRecord的我如何关闭日志特定查询 [英] Rails ActiveRecord How Can I turn off logging particular queries
本文介绍了Rails的ActiveRecord的我如何关闭日志特定查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我下Rails开发模式。
我试图插入二进制数据的记录使用AR为DB。
I am under developer mode in Rails.
I am trying to insert a record with binary data to DB using AR.
Edoc.create(
:id_claim => @claim_index,
:id_material => @doc_code,
:size => @file_list.first[:size],
:efile => params[:files][0].read
)
不过,这需要大量的时间,因为Rails的记录与整个文件内容的查询。
But It takes a lot of time because Rails logs that query with entire file content.
如何关闭日志记录特定的查询?
How Can I turn off logging particular queries?
推荐答案
尝试:
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
# your code here...
还原记录:
ActiveRecord::Base.logger = old_logger; nil # nil just to suppress some garbage
这篇关于Rails的ActiveRecord的我如何关闭日志特定查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文