Skip to content

Instantly share code, notes, and snippets.

@marcotc
Last active February 11, 2021 14:02
Show Gist options
  • Save marcotc/1dcbb62262d75357f7ad29e41c07ea50 to your computer and use it in GitHub Desktop.
Save marcotc/1dcbb62262d75357f7ad29e41c07ea50 to your computer and use it in GitHub Desktop.
ActiveRecord debug query caller
::ActiveSupport::Notifications.subscribe('sql.active_record') do |_, _, _, _, payload|
puts " == Query : #{payload[:sql]}"
puts " == Caller: #{caller.reject{|x|x.include?('/gems/')||x.include?('/lib/ruby/')}.join("\n")}"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment