Hide database queries in Rails console


Most of the time I think it’s useful to see what database queries your commands are generating in the Rails console. The rest of the time the output gets in the way by spamming your console output. It is really easy to turn this logging on and off from inside the console, just run the following command when you want to silence the output:

ActiveRecord::Base.logger.level = 1

This will set the logger’s level to INFO. Then to turn it back on enter:

ActiveRecord::Base.logger.level = 0

This will set the logger’s level back to DEBUG.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s