Skip to content

Instantly share code, notes, and snippets.

@bakineggs
Created June 26, 2010 00:43
Show Gist options
  • Select an option

  • Save bakineggs/453645 to your computer and use it in GitHub Desktop.

Select an option

Save bakineggs/453645 to your computer and use it in GitHub Desktop.
# if you want to figure out wtf is calling Foo::Bar#baz, just
class Foo::Bar
def baz_with_backtrace *args
begin
raise
rescue => e
puts 'backtrace to who called Foo::Bar#baz:'
puts e.backtrace.join("\n")
end
baz_without_backtrace *args
end
alias_method_chain :baz, :backtrace # if you use ActiveSupport, otherwise uncomment the next two lines
# alias_method :baz_without_backtrace, :baz
# alias_method :baz, :baz_with_backtrace
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment