Browse Source

redirect_to :back deprecated in Rails 5.

git-svn-id: http://svn.redmine.org/redmine/trunk@16596 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang 7 years ago
parent
commit
f6defca16d
1 changed files with 9 additions and 7 deletions
  1. 9
    7
      app/controllers/application_controller.rb

+ 9
- 7
app/controllers/application_controller.rb View 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


Loading…
Cancel
Save