When I run queries (e.g. MyModel.where(...) or record.associated_things) in the console, how can I see the actual database queries being run so I can gain more understanding of what is happening?
MyModel.where(...)
record.associated_things
Enter this line in the console:
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
2.1m questions
2.1m answers
60 comments
57.0k users