Joined if statements and removed duplicated code

This commit is contained in:
Lukas Matt 2014-03-24 11:35:05 -04:00
parent 512d96bda6
commit 045ced0518

View file

@ -14,15 +14,11 @@ class ReportController < ApplicationController
end
def destroy
if report = Report.where(id: params[:id]).first
if report.destroy_reported_item
if (report = Report.where(id: params[:id]).first) && report.destroy_reported_item
flash[:notice] = I18n.t 'report.status.destroyed'
else
flash[:error] = I18n.t 'report.status.failed'
end
else
flash[:error] = I18n.t 'report.status.failed'
end
redirect_to :action => :index
end