mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 12:11:40 +01:00
Fix random NoMethodError
errors on cached CustomFilter
objects (#28521)
This commit is contained in:
parent
3599622b5b
commit
fcfdeadc04
2 changed files with 26 additions and 3 deletions
|
@ -17,8 +17,23 @@
|
||||||
class CustomFilter < ApplicationRecord
|
class CustomFilter < ApplicationRecord
|
||||||
self.ignored_columns += %w(whole_word irreversible)
|
self.ignored_columns += %w(whole_word irreversible)
|
||||||
|
|
||||||
alias_attribute :title, :phrase
|
# NOTE: We previously used `alias_attribute` but this does not play nicely
|
||||||
alias_attribute :filter_action, :action
|
# with cache
|
||||||
|
def title
|
||||||
|
phrase
|
||||||
|
end
|
||||||
|
|
||||||
|
def title=(value)
|
||||||
|
self.phrase = value
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_action
|
||||||
|
action
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_action=(value)
|
||||||
|
self.action = value
|
||||||
|
end
|
||||||
|
|
||||||
VALID_CONTEXTS = %w(
|
VALID_CONTEXTS = %w(
|
||||||
home
|
home
|
||||||
|
|
|
@ -17,7 +17,15 @@ class CustomFilterKeyword < ApplicationRecord
|
||||||
|
|
||||||
validates :keyword, presence: true
|
validates :keyword, presence: true
|
||||||
|
|
||||||
alias_attribute :phrase, :keyword
|
# NOTE: We previously used `alias_attribute` but this does not play nicely
|
||||||
|
# with cache
|
||||||
|
def phrase
|
||||||
|
keyword
|
||||||
|
end
|
||||||
|
|
||||||
|
def phrase=(value)
|
||||||
|
self.keyword = value
|
||||||
|
end
|
||||||
|
|
||||||
before_save :prepare_cache_invalidation!
|
before_save :prepare_cache_invalidation!
|
||||||
before_destroy :prepare_cache_invalidation!
|
before_destroy :prepare_cache_invalidation!
|
||||||
|
|
Loading…
Reference in a new issue