2

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?

Lesha Pipiev
  • 3,251
  • 4
  • 31
  • 65

1 Answers1

0

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 
jdoe
  • 15,665
  • 2
  • 46
  • 48
  • You could use ActiveSupport::BufferedLogger#silence but this method has been deprecated in Rails 3.2. But you can look at the code and make sure that if your query fail you won't leave the logger nil for other queries https://github.com/rails/rails/blob/c9cd0eb2d01c262b987070d739cf1d5e46672c10/activesupport/lib/active_support/buffered_logger.rb#L30 – Cristian Bica May 09 '12 at 20:13
  • I have found another one solution. http://stackoverflow.com/questions/4952073/disable-blob-logging-in-rails-3 – Lesha Pipiev May 10 '12 at 06:30
  • I thought you were asking about temp solution for development mode. – jdoe May 10 '12 at 08:06