This question already has an answer here:<ul><li> <a href="/questions/2936000/how-to-show-sql-queries-run-in-the-rails-console" dir="ltr" rel="nofollow">How to show SQL queries run in the Rails console?</a> <span class="question-originals-answer-count"> 4 answers </span> </li> </ul>
My terminal used to display SQL table insert statements (as it should by default), and now it doesn't. Everything else - for example, GET requests, or local server startup info, or job completion notifications - appear as normal.
For the life of me, I can't figure out what the problem could be. I've been searching for a long time and can't figure out any reason this would happen. Do you have any ideas to point me in the right direction?Answer1:
Put this in either in your .irbrc or .pryrc in your home directory
if defined?(Rails) && !Rails.env.nil? puts '... ActiveRecord and ActiveResource Logger set to STDOUT' logger = Logger.new(STDOUT) ActiveRecord::Base.logger = logger ActiveResource::Base.logger = logger end
You should start to see the sql statements executing in the rails console. Hope this helps