From f17fc5742e539db10e0e430f5218c440849b894c Mon Sep 17 00:00:00 2001 From: afontenot Date: Sat, 26 Nov 2022 14:08:25 -0800 Subject: [PATCH] Clear voter count when poll is reset (#21700) When a poll is edited, we reset the poll and remove all previous votes. However, prior to this commit, the voter count on the poll was not reset. This leads to incorrect percentages being shown in poll results. Fixes #21696 --- app/models/poll.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/poll.rb b/app/models/poll.rb index 1a326e452..af3b09315 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -85,6 +85,7 @@ class Poll < ApplicationRecord def reset_votes! self.cached_tallies = options.map { 0 } self.votes_count = 0 + self.voters_count = 0 votes.delete_all unless new_record? end