Skip to content

Instantly share code, notes, and snippets.

@drusepth
Last active August 31, 2017 21:13
Show Gist options
  • Save drusepth/094980e75c345efd2a49ffa22c98e7fb to your computer and use it in GitHub Desktop.
Save drusepth/094980e75c345efd2a49ffa22c98e7fb to your computer and use it in GitHub Desktop.
before_action do
begin
trace = ApplicationController.class_variable_get(:@@trace_reference)
rescue NameError
trace = TracePoint.new(:call) do |tp|
source_path = tp.path
if source_path.include?('/app/controllers/') || source_path.include?('/app/models/')
begin
puts [
' ' * caller.length,
tp.defined_class.to_s,
'::',
tp.method_id,
' [',
tp.path,
':',
tp.lineno,
']'
].join
rescue
require 'pry'
binding.pry
end
end
end
ApplicationController.class_variable_set(:@@trace_reference, trace)
end
trace.enable
end
after_action do
ApplicationController.class_variable_get(:@@trace_reference).disable
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment