From f7638aa214ecef2400559455c818db4bb70e2241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Thu, 7 Nov 2024 22:12:16 +0800 Subject: [PATCH] fix load engine error --- lib/announcement/engine.rb | 4 ++++ lib/announcement/migrate.rb | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/announcement/engine.rb b/lib/announcement/engine.rb index af949e3..a1278dd 100644 --- a/lib/announcement/engine.rb +++ b/lib/announcement/engine.rb @@ -105,6 +105,10 @@ module Announcement puts ['there_was_no_show_option_method',e] end if File.basename($0) != 'rake' + gem_root = Announcement::Engine.root + require File.join(gem_root, 'app/models/bulletin_feed') + require File.join(gem_root, 'app/models/bulletin_feed_cache') + require File.join(gem_root, 'app/models/anns_cache') begin avoid_page_cache AnnsCache avoid_page_cache BulletinFeedCache diff --git a/lib/announcement/migrate.rb b/lib/announcement/migrate.rb index 8c7befe..f705722 100644 --- a/lib/announcement/migrate.rb +++ b/lib/announcement/migrate.rb @@ -7,10 +7,9 @@ module Announcement require File.join(gem_root, 'app/models/bulletin') require File.join(gem_root, 'app/models/bulletin_feed') require File.join(gem_root, 'app/models/bulletin_feed_cache') + require File.join(gem_root, 'app/models/anns_cache') - require File.join(Announcement::Engine.root, 'app/models/anns_cache') - - setting = AnnouncementSetting.first + setting = AnnouncementSetting.first || AnnouncementSetting.create if !setting.migrate_flag.include?("v1") Bulletin.all.pluck(:id, :title).each do |id, title_translations|