Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you hide database output in Rails console?

In newer version of Rails, I'm guessing from 3 up, database queries are output to the console. This is useful most of the time, but how can you hide it when you do not want to see it?

like image 413
Roger Ertesvag Avatar asked Oct 11 '11 09:10

Roger Ertesvag


2 Answers

A better way of doing this is by typing this into the console:

ActiveRecord::Base.logger.level = 1  

as it prevents problems trying use a pointer to a logger that is set to nil (source: Disable Rails SQL logging in console)

To turn it back on

ActiveRecord::Base.logger.level = 0 
like image 137
Aaron B. Russell Avatar answered Sep 28 '22 16:09

Aaron B. Russell


ActiveRecord::Base.logger = nil 

from here

like image 41
samvermette Avatar answered Sep 28 '22 16:09

samvermette