Prevent users from upvoting their own comments.

This commit is contained in:
evazion
2016-11-06 01:20:10 -06:00
parent 4e48e80e1f
commit 1047d7c96b
2 changed files with 17 additions and 5 deletions

View File

@@ -36,7 +36,10 @@ class CommentVote < ActiveRecord::Base
end
def validate_comment_can_be_down_voted
if is_negative? && comment.creator.is_admin?
if is_positive? && comment.creator == CurrentUser.user
errors.add :base, "You cannot upvote your own comments"
false
elsif is_negative? && comment.creator.is_admin?
errors.add :base, "You cannot downvote an admin comment"
false
else