Skip to content

Instantly share code, notes, and snippets.

@lxneng
Forked from gstark/sqlgrowler.rb
Created July 16, 2010 15:32
Show Gist options
  • Save lxneng/478494 to your computer and use it in GitHub Desktop.
Save lxneng/478494 to your computer and use it in GitHub Desktop.
let-your-sql-growl-in-rails-3
#http://hasmanyquestions.wordpress.com/2010/01/17/let-your-sql-growl-in-rails-3/
module SQLGrowler
class Subscriber < ActiveRecord::Railties::Subscriber
def sql(event)
super
g('%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')])
end
end
def self.enable
if Kernel.respond_to?(:g)
Rails::Subscriber.add :active_record, SQLGrowler::Subscriber.new
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment