From 088dc0ec5a383006952c0b15508af882a4c1109c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 26 May 2022 18:05:47 +0200 Subject: [PATCH] Fix regression in `tootctl search deploy` caused by unloaded attribute (#18514) --- app/models/poll.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index ba08309a15..1a326e452c 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -39,13 +39,12 @@ class Poll < ApplicationRecord before_validation :prepare_options, if: :local? before_validation :prepare_votes_count - - after_initialize :prepare_cached_tallies + before_validation :prepare_cached_tallies after_commit :reset_parent_cache, on: :update def loaded_options - options.map.with_index { |title, key| Option.new(self, key.to_s, title, show_totals_now? ? cached_tallies[key] : nil) } + options.map.with_index { |title, key| Option.new(self, key.to_s, title, show_totals_now? ? (cached_tallies[key] || 0) : nil) } end def possibly_stale?