From f6defca16de748d8481dd857b31322eec0162b20 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 3 Jun 2017 07:51:48 +0000 Subject: [PATCH] redirect_to :back deprecated in Rails 5. git-svn-id: http://svn.redmine.org/redmine/trunk@16596 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6f7ec717f..75d298558 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -454,14 +454,16 @@ class ApplicationController < ActionController::Base # Redirects to the request referer if present, redirects to args or call block otherwise. def redirect_to_referer_or(*args, &block) - redirect_to :back - rescue ::ActionController::RedirectBackError - if args.any? - redirect_to *args - elsif block_given? - block.call + if referer = request.headers["Referer"] + redirect_to referer else - raise "#redirect_to_referer_or takes arguments or a block" + if args.any? + redirect_to *args + elsif block_given? + block.call + else + raise "#redirect_to_referer_or takes arguments or a block" + end end end