announcement-test/temp_file/app/models/concern/member_clean_cache.rb

20 lines
367 B
Ruby
Raw Normal View History

2023-05-06 09:08:51 +00:00
module MemberCleanCache
extend ActiveSupport::Concern
included do
def destroy_cache
if self.class==Page
MemberIndexCache.where(page_id: self.id).destroy_all
else
MemberIndexCache.all.destroy_all
end
end
after_save do
self.destroy_cache
end
before_destroy do
self.destroy_cache
end
end
end