From 442baf838405f542fe59fb8c2f03afa71f7a103e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 18 Nov 2019 12:28:23 +0100 Subject: [PATCH] Remove browser gem direct dependency While the browser gem is great, we don't need it in this case for such a simple usage. There are a few really small differences between this code and the old one: matching `/MSIE/` will return true for Opera 12 and false for certain versions of IE11. Since we're only rendering a comment for IE8 and below, we don't care about IE11, and Opera 12 is six years old and its users won't be affected by the comment. Note we're still using the browser gem because ahoy_matey depends on it, but now it's an indirect dependency. --- Gemfile | 1 - Gemfile.lock | 1 - app/views/layouts/application.html.erb | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 05bc5de5e..1d801c72b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,6 @@ gem "ahoy_matey", "~> 1.6.0" gem "ancestry", "~> 3.0.7" gem "audited", "~> 4.9.0" gem "autoprefixer-rails", "~> 8.2.0" -gem "browser", "~> 2.5.3" gem "cancancan", "~> 2.3.0" gem "ckeditor", "~> 4.3.0" gem "cocoon", "~> 1.2.9" diff --git a/Gemfile.lock b/Gemfile.lock index 596d9764e..68177c2ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -586,7 +586,6 @@ DEPENDENCIES ancestry (~> 3.0.7) audited (~> 4.9.0) autoprefixer-rails (~> 8.2.0) - browser (~> 2.5.3) bullet (~> 5.7.0) byebug (~> 10.0.0) cancancan (~> 2.3.0) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6fa18d05e..33f16faa3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,7 +21,7 @@
<%= render "layouts/header", with_subnavigation: true %> - <% if browser.ie? && cookies["ie_alert_closed"] != "true" %> + <% if request.headers["User-Agent"] =~ /MSIE/ && cookies["ie_alert_closed"] != "true" %>