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>
This commit is contained in:
Lukas Matt 2015-09-14 19:26:02 +02:00
parent 95072d6010
commit a6c3f67ba2

View file

@ -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