我在 Rails 中使用机架迷你分析器效果很好,但在一些编码 session 中,特别是在我处理许多不同的客户端代码时,它会妨碍。 (主要是我的客户端调试工具网络图等)
我正在尝试使用之前的过滤器将其关闭,这也可以查看用户是否有权查看个人资料,但“取消授权”似乎对我没有任何作用。这是我的代码,称为之前过滤器:
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
我也知道有一个设置“Rack::MiniProfiler.config.authorization_mode”,但我找不到有关可能设置的文档,并且没有看到它在代码中使用?现在它告诉我 :allow_all,但是 :allow_none 也不做任何事情。
即使我可以临时在开发环境文件中设置一个值并重新启动服务器,这也能达到我的目的。
最佳答案
获取最新信息并输入:
http://mysite.com?pp=disable
完成后输入
http://mysite.com?pp=enable
请参阅 ?pp=help
了解所有选项:
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)
关于ruby-on-rails - 如何暂时禁用 Rack-Mini-Profiler?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12409544/