]> projects.mako.cc - selectricity/blobdiff - app/models/election.rb
fix bug/typo in plurality results around candidate.id and candidate_id
[selectricity] / app / models / election.rb
index 08ef1a57c025d7fe5192d0dc396b828ada9a12f0..7c15dcfcd785298c1e524702801d69fdfd4f3147 100644 (file)
@@ -86,7 +86,7 @@ class Election < ActiveRecord::Base
   end
   
   def quickvote?
-    self.class == 'QuickVote'
+    self.class == QuickVote
   end
 
   def active?
@@ -141,11 +141,11 @@ class Election < ActiveRecord::Base
       # skip if the voter has not voted or has an unconfirmed vote
       next unless voter.voted?
 
-      plurality_tally << voter.vote.rankings.sort[0].candidate.id
+      plurality_tally << voter.vote.rankings.sort[0].candidate_id
       approval_tally << voter.vote.rankings.sort[0..1].collect \
-        { |ranking| ranking.candidate.id }
+        { |ranking| ranking.candidate_id }
       preference_tally << voter.vote.rankings.sort.collect \
-        { |ranking| ranking.candidate.id }
+        { |ranking| ranking.candidate_id }
     end
     
     @plurality_result = PluralityVote.new(plurality_tally).result

Benjamin Mako Hill || Want to submit a patch?