Ruby on rails 为什么可以';为非管理员用户取消授权Rack mini profiler
我正在尝试在我的ROR应用程序上安装Rack mini profiler。 我安装了gem,profiler在开发中工作得很好,但是我不能对非管理员用户的特定请求取消授权。 我将以下代码放在我的ApplicationController中的\u过滤器之前Ruby on rails 为什么可以';为非管理员用户取消授权Rack mini profiler,ruby-on-rails,ruby,rubygems,rack-mini-profiler,Ruby On Rails,Ruby,Rubygems,Rack Mini Profiler,我正在尝试在我的ROR应用程序上安装Rack mini profiler。 我安装了gem,profiler在开发中工作得很好,但是我不能对非管理员用户的特定请求取消授权。 我将以下代码放在我的ApplicationController中的\u过滤器之前 def authorize_mini_profiler if current_user.nil? Rack::MiniProfiler.deauthorize_request return elsif i
def authorize_mini_profiler
if current_user.nil?
Rack::MiniProfiler.deauthorize_request
return
elsif is_admin_user
Rack::MiniProfiler.authorize_request
return
end
Rack::MiniProfiler.deauthorize_request
end
在调试中,我看到调用了deauthorize方法,但仍然显示探查器
我甚至试过使用这个代码
def authorize_mini_profiler
Rack::MiniProfiler.deauthorize_request
end
但是,任何用户的每个请求都会显示分析器
有人知道问题出在哪里吗?好吧,对于那些遇到同样问题的人来说 更深层次的调试发现gem被配置为忽略init上的授权机制。为了仅在某些情况下(例如非生产或仅针对管理员用户)启用评测,您需要覆盖
application.rb
中的默认配置(或者最好是某些特定的配置文件):
否则,配置设置为:allowall
Rack::MiniProfiler.config.authorization_mode = :whitelist if Rails.env.production?