ruby-on-rails - 如何暂时禁用 Rack-Mini-Profiler?

标签 ruby-on-rails ruby-on-rails-3 rack-mini-profiler

我在 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/

相关文章:

ruby-on-rails - 2个字段之间的rails presence条件验证

ruby-on-rails - 未初始化的常量 Rack::MiniProfiler 暂存

ruby-on-rails - 如何使用 rack-mini-profiler 进行 ajax 调用?

ruby-on-rails - 如何将 Mini Profiler (ms) 气泡移动到 Rails 中的右侧

ruby-on-rails-3 - rake Assets :为nil:NilClass预编译未定义方法`[]'

ruby-on-rails - 在 Active Admin 中将 bool 值显示为 'Yes' 和 'No'

ruby-on-rails - 如何将 school_id 添加到我的路径中?

ruby-on-rails - 在 Rails Router 中获取异常内容

ruby-on-rails - 使用 activerecord-sqlserver-adapter 时出现 ArgumentError : wrong number of arguments (3 for 2) after upgrading to Rails 3. 1

ruby-on-rails - Rails - 如何检查条件单选按钮?