X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/da8a3c5c6efcad4e4a5424a09c0479f7ee52a9ec..15870a550ddd18192efc71c1355a238e7c7c53e8:/app/models/vote.rb?ds=inline 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