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
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