X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/d06c024c7dddeca27c658b668ed313f3f107d2e6..1e7167aa6d0c20b8e7b54969577c53abe50461c5:/app/models/vote.rb diff --git a/app/models/vote.rb b/app/models/vote.rb index cc42311..12dd64d 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -62,14 +62,19 @@ class Vote < ActiveRecord::Base end def confirm! - self.confirmed = 1 - self.time = Time.now - self.save - - unless self.voter.election.quickvote? - token.destroy and token.reload if token - self.token = Token.new + if self.voter.election.candidates.length == self.rankings.length + self.confirmed = 1 + self.time = Time.now self.save + + unless self.voter.election.quickvote? + token.destroy and token.reload if token + self.token = Token.new + self.save + end + return false + else + return true end end