]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/issues_controller.rb
More whitespace fixes. Attempting to get tests to pass.
[rails.git] / app / controllers / issues_controller.rb
index d31326a7db881196517bebeb7fdbcd6532e69b4b..763c85ef107edc2ea6542cddea82f4a916584fce 100644 (file)
@@ -69,7 +69,6 @@ class IssuesController < ApplicationController
       @issue = Issue.find_or_initialize_by(create_new_issue_params)
       path = "issues.report_strings." + @issue.reportable.class.name.to_s
       @report_strings_yaml = t(path)
-      flash[:referer] = params[:referer]
     end
   end
 
@@ -106,7 +105,7 @@ class IssuesController < ApplicationController
           Notifier.new_issue_notification(@issue.id, User.find(user.user_id)).deliver_now
         end
 
-        redirect_to flash[:referer], :notice => t("issues.create.successful_report")
+        redirect_back "/", :notice => t("issues.create.successful_report")
       end
     else
       redirect_to new_issue_path(:reportable_type => @issue.reportable_type, :reportable_id => @issue.reportable_id, :reported_user_id => @issue.reported_user_id), :notice => t("issues.create.provide_details")
@@ -140,7 +139,7 @@ class IssuesController < ApplicationController
       if @report.save!
         @issue.report_count = @issue.reports.count
         @issue.save!
-        redirect_to flash[:referer], :notice => notice
+        redirect_back "/", :notice => notice
       end
     else
       redirect_to new_issue_path(:reportable_type => @issue.reportable_type, :reportable_id => @issue.reportable_id, :reported_user_id => @issue.reported_user_id), :notice => t("issues.update.provide_details")
@@ -272,4 +271,13 @@ 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