This commit is contained in:
albert
2013-03-08 17:14:40 -05:00
parent a3be5ac4d0
commit 733c64ff2a
2 changed files with 10 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ class CommentVote < ActiveRecord::Base
belongs_to :user
before_validation :initialize_user, :on => :create
validates_presence_of :user_id, :comment_id, :score
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "has already voted for this comment"
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
validate :validate_user_can_vote
validate :validate_comment_can_be_down_voted
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
@@ -27,7 +27,7 @@ class CommentVote < ActiveRecord::Base
def validate_user_can_vote
if !user.can_comment_vote?
errors.add :user, "can not comment vote"
errors.add :base, "You cannot vote on comments"
false
else
true
@@ -36,7 +36,7 @@ class CommentVote < ActiveRecord::Base
def validate_comment_can_be_down_voted
if is_negative? && comment.creator.is_janitor?
errors.add :user, "can not downvote a janitor comment"
errors.add :base, "You cannot downvote a janitor comment"
false
else
true

View File

@@ -19,4 +19,10 @@ en:
creator_id: "You"
post_disapproval:
post: "You"
post_id: "You"
post_id: "You"
comment:
post: "You"
post_id: "You"
comment_vote:
comment: "You"
user_id: "You"