X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/277d9e323c1c9c525c1cea4590dc71bc56aeed06..74373452650a5ef7eff91f8c479d23500ace3c0c:/app/models/vote.rb diff --git a/app/models/vote.rb b/app/models/vote.rb old mode 100755 new mode 100644 index 62944e3..8852fa5 --- 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. Meant to be manipulated and then confirmed + def set_defaults! + self.votes = voter.election.candidates.sort.collect {|c| c.id } self.save end + end