1 2 3 4 5 6 7 8 9 10 11
require 'active_support/notifications' module ActiveRecord class ExplainSubscriber def call(*args) ActiveRecord::Base.collect_queries_for_explain(args.last) end ActiveSupport::Notifications.subscribe("sql.active_record", new) end end