Use rails 5 version of redirect_back.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 12 Jul 2017 12:57:09 +0000 (13:57 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 12 Jul 2017 12:57:09 +0000 (13:57 +0100)
app/controllers/issues_controller.rb

index 63228c79e5b6f62d989d5938b0ed2f569a12b9fe..e3c844d45e703f59eee29300b70d5970e6610ac4 100644 (file)
@@ -103,7 +103,7 @@ class IssuesController < ApplicationController
           Notifier.new_issue_notification(@issue.id, User.find(user.user_id)).deliver_now
         end
 
-        redirect_back "/", :notice => t("issues.create.successful_report")
+        redirect_back :fallback_location => "/", :notice => t("issues.create.successful_report")
       end
     else
       redirect_to new_issue_path(:reportable_type => @issue.reportable_type, :reportable_id => @issue.reportable_id), :notice => t("issues.create.provide_details")
@@ -137,7 +137,7 @@ class IssuesController < ApplicationController
       if @report.save!
         @issue.report_count = @issue.reports.count
         @issue.save!
-        redirect_back "/", :notice => notice
+        redirect_back :fallback_location => "/", :notice => notice
       end
     else
       redirect_to new_issue_path(:reportable_type => @issue.reportable_type, :reportable_id => @issue.reportable_id), :notice => t("issues.update.provide_details")
@@ -269,13 +269,4 @@ class IssuesController < ApplicationController
   def sort_direction
     %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc"
   end
-
-  # back-port of ActionController#redirect_back from rails 5
-  def redirect_back(fallback_location, **args)
-    if referer = request.headers["Referer"]
-      redirect_to referer, **args
-    else
-      redirect_to fallback_location, **args
-    end
-  end
 end