comments: remove rule that you can't upvote your own comments.
Remove this rule for several reasons: * A single upvote usually isn't enough to matter, especially with the new comment threshold. * It felt weird that trying to vote on a comment could fail. * Disabling the upvote button on your own comments feels weird. * Most other sites allow you to upvote your own comments. * You're allowed to upvote your own uploads, so it doesn't make sense that you can't upvote your own comments.
This commit is contained in:
@@ -33,6 +33,8 @@
|
|||||||
* The maximum comment threshold is now 5 and the minumum threshold is now
|
* The maximum comment threshold is now 5 and the minumum threshold is now
|
||||||
-100. You can't set your threshold any higher or lower than this.
|
-100. You can't set your threshold any higher or lower than this.
|
||||||
|
|
||||||
|
* Removed the rule that you can't upvote your own comments.
|
||||||
|
|
||||||
* Changed the way [quote] tags look. Now quotes are Reddit-style instead of
|
* Changed the way [quote] tags look. Now quotes are Reddit-style instead of
|
||||||
traditional forum style.
|
traditional forum style.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ class CommentVote < ApplicationRecord
|
|||||||
|
|
||||||
validates_presence_of :score
|
validates_presence_of :score
|
||||||
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
|
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
|
||||||
validate :validate_comment_can_be_down_voted
|
|
||||||
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
||||||
|
|
||||||
after_create :update_score_after_create
|
after_create :update_score_after_create
|
||||||
@@ -25,12 +24,6 @@ class CommentVote < ApplicationRecord
|
|||||||
q.apply_default_order(params)
|
q.apply_default_order(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_comment_can_be_down_voted
|
|
||||||
if is_positive? && comment.creator == CurrentUser.user
|
|
||||||
errors.add(:base, "You cannot upvote your own comments")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def is_positive?
|
def is_positive?
|
||||||
score == 1
|
score == 1
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user