|
|
@ -41,7 +41,7 @@ class CustomFilter < ApplicationRecord
|
|
|
|
validates :title, :context, presence: true
|
|
|
|
validates :title, :context, presence: true
|
|
|
|
validate :context_must_be_valid
|
|
|
|
validate :context_must_be_valid
|
|
|
|
|
|
|
|
|
|
|
|
before_validation :clean_up_contexts
|
|
|
|
normalizes :context, with: ->(context) { context.map(&:strip).filter_map(&:presence) }
|
|
|
|
|
|
|
|
|
|
|
|
before_save :prepare_cache_invalidation!
|
|
|
|
before_save :prepare_cache_invalidation!
|
|
|
|
before_destroy :prepare_cache_invalidation!
|
|
|
|
before_destroy :prepare_cache_invalidation!
|
|
|
@ -114,10 +114,6 @@ class CustomFilter < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
|
|
def clean_up_contexts
|
|
|
|
|
|
|
|
self.context = Array(context).map(&:strip).filter_map(&:presence)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def context_must_be_valid
|
|
|
|
def context_must_be_valid
|
|
|
|
errors.add(:context, I18n.t('filters.errors.invalid_context')) if invalid_context_value?
|
|
|
|
errors.add(:context, I18n.t('filters.errors.invalid_context')) if invalid_context_value?
|
|
|
|
end
|
|
|
|
end
|
|
|
|