I am attempting to visualize / understand my Rails application hierarchy on each page request. I thought that perhaps a puts caller would do the trick, however I’m not wanting a highly verbose trace through the Rails framework itself.
I only primarily want dependent scripts in my own Rails app over which I essentially have control. I could say (inaccurately) that I’d like for, when a request is made, that in the console it would print out the root script that is being called and then all of it’s links on up to the last view erb / haml, etc.
How can I accomplish something like this without putting a puts statement in each file in my Rails app at the head and end of each one?
If I insert a puts "-> #{File.expand_path(File.dirname(__FILE__))}/#{File.basename(__FILE__)}" into each of the Rails app files, that can more or less accomplish what I’m trying to get to, however would something along the lines of this “Show full path name of the ruby file when it get loaded” do the trick more appropriately without modifying all kinds of files; keeping it DRY?
You could filter output of
Kernel#callerby checking filename. If it’s in your project directory, then print it. Otherwise, ignore.