From b23704a9660043ade4a4073c706cbc65ca9764c9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 24 Jul 2019 14:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/department.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/department.rb b/app/models/department.rb index bf5c3a90e..c019862db 100644 --- a/app/models/department.rb +++ b/app/models/department.rb @@ -3,8 +3,7 @@ class Department < ApplicationRecord has_many :department_members, dependent: :destroy - after_create_commit :reset_data_cache - after_update_commit :reset_data_cache + after_commit :reset_data_cache def self.cached_names_data(school) Rails.cache.fetch(names_data_cache_key(school.id), expires_in: 7.days) do @@ -16,9 +15,7 @@ class Department < ApplicationRecord def reset_data_cache # 清除部门名称缓存 - if new_record? || name_previously_changed? - Rails.cache.delete(self.class.names_data_cache_key(school_id)) - end + Rails.cache.delete(self.class.names_data_cache_key(school_id)) end def self.names_data_cache_key(school_id)