Skip to content

Commit

Permalink
normalize the vote and the voter_id
Browse files Browse the repository at this point in the history
  • Loading branch information
dcu committed Aug 2, 2012
1 parent 79ef498 commit 9ec976d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mongoid_ext/voteable.rb
Expand Up @@ -20,10 +20,13 @@ def voted?(voter_id)
end

def vote!(value, voter_id, &block)
value = value.to_i
voter_id = voter_id.to_s

old_vote = self.votes[voter_id]
if !old_vote
self.votes[voter_id] = value
self.save(:validate => false)
self.save

add_vote!(value, voter_id, &block)
return :created
Expand Down

0 comments on commit 9ec976d

Please sign in to comment.