How to temporarily disable Rack-Mini-Profiler?

I use the rack profiler in rails just fine, but during some coding sessions, especially when I work on a lot of different client codes, this gets in the way. (mainly on graphs of network debugging tools on the client side, etc.)

I am trying to disable it using the before filter, which also shows if the user is allowed to view the profile, but "deauthorize" seems to do nothing for me. Here my code is called as before filter:

def miniprofiler off = true if off || !current_user Rack::MiniProfiler.deauthorize_request return elsif current_user.role_symbols.include?(:view_page_profiles) Rack::MiniProfiler.authorize_request return end Rack::MiniProfiler.deauthorize_request end 

I also know that there is a parameter "Rack :: MiniProfiler.config.authorization_mode", but I can not find documents about possible settings and not see that it is used in the code? Now he tells me: allow_all, but: allow_none does nothing.

Even if I can just temporarily set the value in the dev environment file and restart the server, which will serve my purpose.

+42
ruby-on-rails ruby-on-rails-3
Sep 13
source share
3 answers

Get the latest and print:

http://mysite.com?pp=disable

When you're done, enter

http://mysite.com?pp=enable

See ?pp=help for all options:

 Append the following to your query string:

   pp = help: display this screen
   pp = env: display the rack environment
   pp = skip: skip mini profiler for this request
   pp = no-backtrace: don't collect stack traces from all the SQL executed (sticky, use pp = normal-backtrace to enable)
   pp = normal-backtrace (*): collect stack traces from all the SQL executed and filter normally
   pp = full-backtrace: enable full backtraces for SQL executed (use pp = normal-backtrace to disable) 
   pp = sample: sample stack traces and return a report isolating heavy usage (experimental works best with the stacktrace gem)
   pp = disable: disable profiling for this session 
   pp = enable: enable profiling for this session (if previously disabled)
   pp = profile-gc: perform gc profiling on this request, analyzes ObjectSpace generated by request (ruby 1.9.3 only)
   pp = profile-gc-time: perform built-in gc profiling on this request (ruby 1.9.3 only)
+78
Sep 20 '12 at 6:20
source share

You can also use Alt+p to switch.

+21
May 24 '13 at 19:59
source share

If you want the profiler to be disabled initially, and then activate on demand ... add a preliminary authorization callback in the initialization file, for example:

 Rack::MiniProfiler.config.pre_authorize_cb = lambda {|env| ENV['RACK_MINI_PROFILER'] == 'on'} 

then in your application controller add before_filter parameter which looks for pp param parameter

 before_filter :activate_profiler def activate_profiler ENV['RACK_MINI_PROFILER'] = 'on' if params['pp'] ENV['RACK_MINI_PROFILER'] = 'off' if params['pp'] == 'disabled' end 

RACK_MINI_PROFILER will not be set in your environment, but if you want to enable it, can you apply? pp = enabled on its url. Then you can turn it off again later (pp = disabled will turn it off only for the current session, but if you disable the ENV variable, it will turn off completely until you turn it on).

+2
Mar 12 '15 at 19:00
source share



All Articles