From 0a1edce5e00e0d1fc6bedb35819390b898799152 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 21 Jul 2017 13:42:40 +0200 Subject: [PATCH 1/2] Add rack_mini_profiler --- Gemfile | 2 ++ Gemfile.lock | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index c6ed17aae..9b4d7a0bf 100644 --- a/Gemfile +++ b/Gemfile @@ -109,6 +109,8 @@ gem 'prawn_rails', '~> 0.0.11' gem 'chunky_png' gem 'sentry-raven' +gem 'rack-mini-profiler' + group :test do gem 'capybara' gem 'launchy' diff --git a/Gemfile.lock b/Gemfile.lock index 1f6a4eee2..fca30b5c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -448,6 +448,8 @@ GEM rack (2.0.1) rack-handlers (0.7.3) rack + rack-mini-profiler (0.10.5) + rack (>= 1.2.0) rack-oauth2 (1.4.0) activesupport (>= 2.3) attr_required (>= 0.0.5) @@ -725,6 +727,7 @@ DEPENDENCIES prawn_rails (~> 0.0.11) pry-byebug rack-handlers + rack-mini-profiler rails (= 5.0.0.1) rails-controller-testing redis From d097860b049eed567ea54922cfbc1a3b80278fc0 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 24 Jul 2017 12:29:09 +0200 Subject: [PATCH 2/2] Enable rack mini profiler when super admin is connected --- app/controllers/application_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 191d2bcf8..fbaba5b73 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,13 @@ class ApplicationController < ActionController::Base before_action :check_browser before_action :load_navbar_left_pannel_partial_url before_action :set_raven_context + before_action :authorize_request_for_profiler + + def authorize_request_for_profiler + if Rails.env.production? && administration_signed_in? + Rack::MiniProfiler.authorize_request + end + end def default_url_options return {protocol: 'https'} if Rails.env.staging? || Rails.env.production?