4

I managed to get rack-mini-profiler gem to run fine on the full pages we serve in our app. What I didn't manage is, how to directly get the data also for one of the calls we serve via ajax to another page. I found, that if I do the ajax call and then call one of our full page requests, I see also the ajax timing, but this is kind of cumbersome to do.

Do you have any tips on how to see the small menu also directly on the page where the ajax call is done? Our ajax call is returning html and there would be enough space to show the menu.

Bruno E.
  • 1,284
  • 11
  • 16
  • I'm looking at this problem myself now. Breaking it down, I think we'd need to append the profiler parameters to your AJAX call (or default the profiler to be on), and then ensure that your response template includes the profile data. And then communicate that to a rendering function if necessary. – Rich Seviora Dec 22 '16 at 19:04
  • @RichSeviora I am interested in profiling AJAX requests as well. Looks like there are some mini profiler headers in my AJAX requests already using default gem setup. I wonder if it is just a matter of implementing your last suggestion: `and then ensure that your response template includes the profile data. And then communicate that to a rendering function if necessary.` I am going to try and look into this. I bet there's no profile data in response because my api controllers are subclass of `ActionController::API` and not `ActionController::Base`, which is probably what the gem hooks into. – RudyOnRails Mar 29 '19 at 00:50

2 Answers2

3

My apologies for responding with an indirect answer to your question. But, I highly recommend the Chrome Extension (and associated gems) Rails Panel, particularly for investigating Ajax/Async calls with Rails.

I use it daily at work and find it to be a great tool.

craig.kaminsky
  • 5,588
  • 28
  • 31
  • 1
    Thanks for pointing me to Rails Panel. I think it should be highlighted that a possible difference between Rails Panel and rack-mini-profiler is that mini-profiler has the ability to perform memory profiling whereas Rails Panel does not. – Marklar Oct 13 '16 at 02:39
0

Once you've added rack-miniprofiler to your bundle, then you need to set disable_caching = true. You can do this in an initializer:

# config/initializers/rack_profiler.rb
if Rails.env.development?
  Rack::MiniProfiler.config.disable_caching = true
end
builder-7000
  • 7,131
  • 3
  • 19
  • 43