Created a partial to DRY the aja voting method. Modified the voter class to
[selectricity-live] / app / models / vote.rb
index 62944e3301a5b6f07f77f475e1ef85ae8d314cc6..dcadcac91d5db2bcd4158825b9098ab7e788e708 100644 (file)
@@ -7,9 +7,7 @@ class Vote < ActiveRecord::Base
   # callbacks
   after_update :save_rankings
   before_destroy :destroy_rankings
-
   
-
   def to_s
     votes.join("")
   end
@@ -76,7 +74,7 @@ class Vote < ActiveRecord::Base
   def votestring=(string="")
     candidate_ids = voter.election.candidates.sort.collect \
       { |candidate| candidate.id.to_i }
-
+      
     rel_votes = string.split("").collect { |vote| vote.to_i }
     
     # covert relative orders to absolute candidate ids
@@ -95,11 +93,12 @@ class Vote < ActiveRecord::Base
     self.votes.collect {|v| cand_relnums[v]}.join("")
   end
 
-  # the following subroutine is used for quickvotes. it creates a vote
-  # with the candidates listed in order of preference based on
-  # alphabetical order. it is meant to be manipulated and then confirmed
-  def set_defaults!
-    self.votes =  voter.election.candidates.sort.collect {|c| c.id }
+  # the following subroutine is used for quickvotes, but need for elections now
+  # too. It creates a vote with the candidates listed in order of preference 
+  # based on alphabetical order. It is meant to be manipulated and then confirmed
+  def set_defaults!  
+    self.votes = voter.election.candidates.sort.collect {|c| c.id }
     self.save
   end
+         
 end

Benjamin Mako Hill || Want to submit a patch?