Skip to content
This repository
Browse code

simplifies ActiveRecord::ExplainSubscriber [José Valim & Xavier Noria]

  • Loading branch information...
commit 7f3ce35e1947c31233263a2cd48740646f5585b3 1 parent d59bfeb
Xavier Noria fxn authored

Showing 1 changed file with 6 additions and 8 deletions. Show diff stats Hide diff stats

  1. +6 8 activerecord/lib/active_record/explain_subscriber.rb
14 activerecord/lib/active_record/explain_subscriber.rb
... ... @@ -1,13 +1,11 @@
1   -module ActiveRecord
2   - class ExplainSubscriber < ActiveSupport::LogSubscriber
3   - def sql(event)
4   - ActiveRecord::Base.collect_queries_for_explain(event.payload)
5   - end
  1 +require 'active_support/notifications'
6 2
7   - def logger
8   - ActiveRecord::Base.logger
  3 +module ActiveRecord
  4 + class ExplainSubscriber
  5 + def call(*args)
  6 + ActiveRecord::Base.collect_queries_for_explain(args.last)
9 7 end
10 8
11   - attach_to :active_record
  9 + ActiveSupport::Notifications.subscribe("sql.active_record", new)
12 10 end
13 11 end

0 comments on commit 7f3ce35

Please sign in to comment.
Something went wrong with that request. Please try again.