How to see the sql statements for rails commands

Just type the fol­low­ing com­mand in your rails con­sole to see the sql out­put of your rails commands

ActiveRecord::Base.logger =

NOTE: You will prob­a­bly have to do this for every session.

To avoid that, add the fol­low­ing to your ~/.irbrc file


require 'rubygems' if ENV.include?('RAILS_ENV') && ENV["RAILS_ENV"] == 'development' ActiveRecord::Base.logger = end

Ryan Sukale

Ryan is a UX engineer living in San Francisco, California.

You may also like...