How to show SQL statements in Rails console like WEBrick?

ruby-on-rails

Solution

To do this you have to enable logger, you could do this as follows.

Open the rails console:

ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)

Have a look at this link:

http://rubyquicktips.com/post/292826666/display-activerecord-generated-sql-queries-in-the

Problem

Rails WEBrick shows raw SQL statements for any ActiveRecord activities. How to enable that in the console?

Original source