简体   繁体   中英

Rails ActiveRecord How Can I turn off logging particular queries

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
        )   

But It takes a lot of time because Rails logs that query with entire file content.

How Can I turn off logging particular queries?

Try:

old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
# your code here...

Restore logger:

ActiveRecord::Base.logger = old_logger; nil # nil just to suppress some garbage 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM