X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/da8a3c5c6efcad4e4a5424a09c0479f7ee52a9ec..5c62b1606f7f89efdd5a6c51308cd0212fe9a709:/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