X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/99e1580f0d7707b8e2f8c08f8aae70c3d4906637..ee280d9250b5b4c925cc6b4809ce40437d600e7d:/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