From a6c3f67ba2ff7f1877f0a239f3cc33d5e559aa45 Mon Sep 17 00:00:00 2001
From: Lukas Matt <lukas@zauberstuhl.de>
Date: Mon, 14 Sep 2015 19:26:02 +0200
Subject: [PATCH] Check if post or comment exist while rendering

It is possible that the item was deleted
during the time it was reported and the admin review

Signed-off-by: Lukas Matt <lukas@zauberstuhl.de>
---
 app/controllers/report_controller.rb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb
index 8e0826c1f4..14e9001f17 100644
--- a/app/controllers/report_controller.rb
+++ b/app/controllers/report_controller.rb
@@ -7,7 +7,10 @@ class ReportController < ApplicationController
   before_action :redirect_unless_moderator, except: [:create]
 
   def index
-    @reports = Report.where(reviewed: false)
+    @reports ||= []
+    Report.where(reviewed: false).each do |report|
+      @reports << report unless report.item.nil?
+    end
   end
 
   def update
-- 
GitLab