X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/9129a21b28c88064edfcfc8a8fa23a640f29819c..20cae2b9f1107273ddf18cd9d5f78d873ec9afd2:/app/models/vote.rb?ds=sidebyside diff --git a/app/models/vote.rb b/app/models/vote.rb index bef3502..d3010df 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -39,7 +39,7 @@ class Vote < ActiveRecord::Base if rankings.empty? @votes = Array.new else - @votes = rankings.sort.collect { |ranking| ranking.candidate.id } + @votes = self.rankings.sort.collect { |ranking| ranking.candidate.id } end end @@ -51,6 +51,9 @@ class Vote < ActiveRecord::Base end def save_rankings + self.votes # i need to initalize this before destroying rankings + # or else the ranks themselves show up as nil + destroy_rankings self.votes.each_with_index do |candidate_id, index| ranking = Ranking.new