Skip to content

Instantly share code, notes, and snippets.

@bmorton
Created April 4, 2013 21:11
Show Gist options
  • Save bmorton/5314394 to your computer and use it in GitHub Desktop.
Save bmorton/5314394 to your computer and use it in GitHub Desktop.
Throw this in an initializer to get stack traces of SQL queries.
ActiveSupport::Notifications.subscribe "sql.active_record" do |name, start, finish, id, payload|
Rails.logger.debug "=============================================="
Rails.logger.debug "SQL: #{payload[:sql]}"
Rails.logger.debug "=============================================="
Rails.logger.debug caller.join("\n")
Rails.logger.debug "=============================================="
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment