X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/c65b1e11059c5cf510b54c785d4a246215058f70..8f23a174c70223831055e1498b50c3ba260858fe:/app/models/vote.rb?ds=sidebyside diff --git a/app/models/vote.rb b/app/models/vote.rb index 62944e3..dcadcac 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -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