]> source.dussan.org Git - redmine.git/commitdiff
redirect_to :back deprecated in Rails 5.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 3 Jun 2017 07:51:48 +0000 (07:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 3 Jun 2017 07:51:48 +0000 (07:51 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16596 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb

index 6f7ec717fbf424cc08df18fe3e1f9f913599a16f..75d298558e079f789cc1a260b5c84b4fc080c3a9 100644 (file)
@@ -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