all posts

Log SQL queries in the Rails console

Tipsy tip

Adrian Marin

60 words 1 min read

When debug queries in the console I often want to see the raw DB queries being made.

Here's a quick little piece of code which will make those queries visible in the console.

ActiveRecord::Base.logger = Logger.new(STDOUT)

This will tell the ActiveRecord logger to log out to STDOUT which is what we're using in the console.

Join the newsletter

Rails guides, Avo releases, and useful lessons from building the admin layer.

No noise. Unsubscribe whenever you like. Read our privacy policy.