We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f0a1637 commit 8edc744Copy full SHA for 8edc744
1 file changed
app/models/poll.rb
@@ -32,8 +32,11 @@ class Poll < ApplicationRecord
32
scope :attached, -> { where.not(status_id: nil) }
33
scope :unattached, -> { where(status_id: nil) }
34
35
+ before_validation :prepare_options
36
before_validation :prepare_votes_count
37
+
38
after_initialize :prepare_cached_tallies
39
40
after_commit :reset_parent_cache, on: :update
41
42
def loaded_options
@@ -75,6 +78,10 @@ def prepare_votes_count
75
78
self.votes_count = cached_tallies.sum unless cached_tallies.empty?
76
79
end
77
80
81
+ def prepare_options
82
+ self.options = options.map(&:strip).reject(&:blank?)
83
+ end
84
85
def reset_parent_cache
86
return if status_id.nil?
87
Rails.cache.delete("statuses/#{status_id}")
0 commit comments