Reputation: 14051
Whereas the verbose feature of SQL/ActiveRecord calls is useful most of the time, I would like to turn it off in cases where I have some looping going on.
Is there a way to turn it off?
irb(main):055:0> City.first
←[1m←[35mCity Load (1.0ms)←[0m SELECT `cities`.* FROM `cities` LIMIT 1
=> #<City id: 1, name: "bla bla", state_id: 1, zip: nil, country_id: nil,
created_at: "2011-03-27 14:11:28", updated_at: "2011-08-16 11:14:36", guid: "5PK
fvvz2Gsi">
Upvotes: 22
Views: 18870
Reputation: 3710
You can try to place this code in your rails_spec.rb file.
config.before do
ActiveRecord::Base.logger.level = 1
end
It did the trick for me.
Upvotes: 1
Reputation: 9368
In Rails 4 I've been annoyed by ActiveRecord logging SQL statements in the middle of my specs so I disable it by adding this to config/environments/test.rb
:
Rails.application.configure do
# ...
config.log_level = :info
end
Upvotes: 5
Reputation: 11967
In console:
Disable:
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
Enable:
ActiveRecord::Base.logger = old_logger
Upvotes: 26