RSS Feed

Working @GitHub Support, programming for fun, working remotely, love cooking and food, and want to learn how to play the guitar.

How to show generated SQL by ActiveRecord in Rails console

Published on 2010-07-07

There are times when we want to see the SQL ActiveRecord generates. We can do it easily by issuing the following statement as soon as we run script/console:

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

Now each time we issue an ActiveRecord statement, we'll get the SQL first.



blog comments powered by Disqus