Skip to content

Instantly share code, notes, and snippets.

@radar
Created April 4, 2013 05:15
Show Gist options
  • Save radar/5308002 to your computer and use it in GitHub Desktop.
Save radar/5308002 to your computer and use it in GitHub Desktop.
before do
ActiveSupport::Notifications.subscribe('sql.active_record') do |name, starts_at, ends_at, id, payload|
if /stock_items/.match(payload[:sql]) && /INSERT/.match(payload[:sql])
puts caller.delete_if { |p| !p.include?("/Users/ryan/Sites/gems/spree") }.join("\n")
puts "*" * 100
end
end
end
@jlecour
Copy link

jlecour commented Apr 4, 2013

This is simple and clever.

Where do you put this ?
Given it's a AS::N subscribe block I would have put it in an initializer, but the before block is not familiar.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment