在新版本的 Rails 中,我猜测从3开始,数据库查询被输出到控制台。这在大多数情况下是有用的,但是当您不想看到它时,如何隐藏它呢?
Short answer... In the file development.rb change or add the value of config.log_level so that there's a line like
config.log_level
config.log_level = :info
ActiveRecord::Base.logger = nil
from here
From a friend of mine:
your_query; nil
I see you already got your needed answer although I would like to advise the 'quiet assets' gem to you, most of the log data will be asset compiling and inclusions, this gem will remove that and still output the queries and data behavior.
Have fun
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
In Rails 3.2, setting
config.logger.level = Logger::INFO
worked fine for me for turning off SQL output.