Last active
April 18, 2016 06:58
-
-
Save r7kamura/3252461bc79558f296f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload| | |
if payload[:sql] =~ /\A(?!EXPLAIN).*SELECT.+FROM/ | |
ActiveRecord::Base.logger.warn( | |
ActiveRecord::Base.connection.explain(payload[:sql], payload[:binds]) | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For instance, you can inspect SQL consistency with testing like this: