X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/2facf9c3cba1ddc270c84a713cafbe6eb7280efd..4446a6555bd54ca10a925340bb65c706678ac98e:/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