Last active
August 31, 2017 21:13
-
-
Save drusepth/094980e75c345efd2a49ffa22c98e7fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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