diff --git a/lib/tasks/migrate_course_resource.rake b/lib/tasks/migrate_course_resource.rake index d3095c6dd..628d84de2 100644 --- a/lib/tasks/migrate_course_resource.rake +++ b/lib/tasks/migrate_course_resource.rake @@ -17,7 +17,7 @@ namespace :migrate_course_resource do if atta.course_second_category.present? target_category = CourseSecondCategory.find_by(name: atta.course_second_category.name, course_id: target_course.id, category_type: "attachment") unless target_category.present? - course_module = Course.course_modules.find_by(module_type: "attachment") + course_module = target_course.course_modules.find_by(module_type: "attachment") target_category = CourseSecondCategory.create(name: atta.course_second_category.name, course_id: target_course.id, category_type: "attachment", course_module_id: course_module&.id, position: course_module&.course_second_categories&.count.to_i + 1)