Whenever we use ruby script/console during development, we often would like to see the SQL queries instantly that get being generated at the backend. Those queries can be a result of method calls on model, named scope, etc.
We just need to execute the below 2 lines to have this enabled on console.
ActiveRecord::Base.logger = Logger.new(STDOUT)
And now whenever we will interact with ActiveRecord object method calls, the SQL query will get displayed immediately in the console.