diff --git a/app/controllers/initialization_data_controller.rb b/app/controllers/initialization_data_controller.rb
index fb5375692..c71ea1968 100644
--- a/app/controllers/initialization_data_controller.rb
+++ b/app/controllers/initialization_data_controller.rb
@@ -67,7 +67,7 @@ class InitializationDataController < ApplicationController
     logger.info("#########test_sets: #{@test_sets.map(&:id)}")
     logger.info("#########challenge_chooses: #{@challenge_chooses.map(&:id)}")
     logger.info("#########challenge_questions: #{@challenge_questions.map(&:id)}")
-    logger.info("#########attachments: #{@att_ids.count}")
+    logger.info("#########attachments: #{@attachments.count}")
     connect_to_origin_date database
     logger.info("#########subjects: #{@subjects.count}")
     logger.info("#########stage: #{@stages.count}")
@@ -83,7 +83,7 @@ class InitializationDataController < ApplicationController
     logger.info("#########test_sets: #{@test_sets.count}")
     logger.info("#########challenge_chooses: #{@challenge_chooses.count}")
     logger.info("#########challenge_questions: #{@challenge_questions.count}")
-    logger.info("#########attachments: #{@att_ids}")
+    logger.info("#########attachments: #{@attachments.count}")
     ActiveRecord::Base.transaction do
        copy_subject_data
        copy_stages_data
@@ -386,21 +386,22 @@ class InitializationDataController < ApplicationController
   # 获取关卡附件
   def get_attachment_data
     task_pass = Challenge.where(id: @challenges).where("task_pass like '%/api/attachments/%'").pluck(:task_pass)
-    @att_ids = []
+    att_ids = []
     # 附件的格式为(/api/attachments/ + 附件id)的形式,因此下面的正文匹配是为了取出附件的id,方便迁移attachments
     task_pass.each do |tp|
-      @att_ids += tp.scan(/\(\/api\/attachments\/.+\)/).map{|s|s.match(/\d+/)[0]}
+      att_ids += tp.scan(/\(\/api\/attachments\/.+\)/).map{|s|s.match(/\d+/)[0]}
     end
+    @attachments = Attachment.where(id: att_ids).to_a
   end
 
   # 创建附件数据
   def copy_attachment_data
-    return if @att_ids.blank?
-    attachment_attrs = %i[id container_id container_type filename disk_filename filesize content_type digest author_id created_on
-    downloads description disk_directory attachtype is_public copy_from quotes is_publish publish_time resource_bank_id unified_setting
+    return if @attachments.blank?
+    attachment_attrs = %i[id container_id container_type filename disk_filename filesize content_type digest downloads author_id
+    created_on description disk_directory attachtype is_public copy_from quotes is_publish publish_time resource_bank_id unified_setting
     cloud_url course_second_category_id]
     Attachment.bulk_insert(*attachment_attrs) do |worker|
-      Attachment.where(id: @att_ids).each do |att|
+      @attachments.each do |att|
         logger.info("########att_id: #{att.id}")
         base_attr = att.attributes.dup.except("author_id", "disk_directory", "copy_from")
         # 本地版将过关任务的图片迁移到files/localshixuns 目录下, copy_from记录的是他原来的目录结构