From 409fb22fd2a060812cb45d55bea8a57b1135dcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Tue, 8 Feb 2022 15:45:06 +0800 Subject: [PATCH] fix error --- app/models/bulletin.rb | 2 +- lib/bulletin_model/cache.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index f4a8439..72d98a8 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -9,7 +9,7 @@ class Bulletin include OrbitCategory::Categorizable include Slug require 'bulletin_model/cache' - include ::BulletinModel::Cache + include BulletinModel::Cache attr_accessor :org_tag_ids def tags=(ids) self.org_tag_ids = self.tag_ids diff --git a/lib/bulletin_model/cache.rb b/lib/bulletin_model/cache.rb index 190c0f4..6317e96 100644 --- a/lib/bulletin_model/cache.rb +++ b/lib/bulletin_model/cache.rb @@ -3,12 +3,12 @@ module BulletinModel require 'active_support/concern' extend ActiveSupport::Concern included do - before_save :do_before_save - before_destroy :do_before_save + after_save :do_before_save + after_destroy :do_before_save end def do_before_save if self.class == SubPart - AnnsCache.where(parent_id:self.id).destroy + AnnsCache.where(parent_id: self.id).destroy elsif self.class == Bulletin || (self.class == Page && self.module == "announcement") if self.class == Bulletin tmp_tag_ids = (Array(self.tag_ids) + Array(self.org_tag_ids)).uniq