add thread deleting

This commit is contained in:
jomo
2014-04-21 01:53:32 +02:00
parent 12ffc28681
commit 6b5ed6ea7f

View File

@@ -56,6 +56,19 @@ class ForumthreadsController < ApplicationController
end end
def destroy
if mod? || @thread.author.is?(current_user)
if @thread.destroy
flash[:notice] = "Thread deleted!"
else
flash[:alert] = "There was a problem while deleting this thread"
end
else
flash[:alert] = "You are not allowed to delete this thread"
end
redirect_to @thread.forum
end
private private
def check_permission def check_permission