Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do ActiveRecord queries from console print sql statements?

I'm using pry, and ActiveRecord queries from the console always print out their corresponding SQL statements. I don't want this behavior. Googling around I only see that this must be explicitly achieved by setting the ActiveRecord logger to standard out.

Is this the default behavior of pry or is it the result of something I set that I forgot about? And how can I stop it?

like image 284
John Bachir Avatar asked Apr 20 '26 20:04

John Bachir


1 Answers

Try looking for a .irbrc file in the project root or your home directory. You may see this or similar:

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

Sometimes this ends up in another script that gets included in .irbrc.

YMMV, but I really like having SQL logged to the console. To each his own...

like image 109
zetetic Avatar answered Apr 23 '26 22:04

zetetic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!