X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/ad088c1324d08a65f6f5336bedf7a88a8a8950e7..9a15981ecd4893c6ca1e6c0e89da0b497824d1f9:/app/models/vote.rb diff --git a/app/models/vote.rb b/app/models/vote.rb index d3010df..719aa7b 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -73,14 +73,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