fixes #69: Comment voting non functional

This commit is contained in:
albert
2011-09-14 17:46:42 -04:00
parent fcc6a78fd4
commit 22074eed1f
10 changed files with 73 additions and 31 deletions

View File

@@ -38,15 +38,18 @@ class Comment < ActiveRecord::Base
end
def vote!(score)
vote = votes.create(:score => score)
numerical_score = score == "up" ? 1 : -1
vote = votes.create(:score => numerical_score)
if vote.errors.any?
raise CommentVote::Error.new(vote.errors.full_messages.join("; "))
elsif vote.is_positive?
increment!(:score)
elsif vote.is_negative?
decrement!(:score)
if vote.errors.empty?
if vote.is_positive?
increment!(:score)
elsif vote.is_negative?
decrement!(:score)
end
end
return vote
end
def creator_name