الإضافة تظهر خطأ HasCustomFields::NotPreloadedError

field = 'video_url'
register_post_custom_field_type(field, :string)
register_topic_custom_field_type(field, :string)
add_preloaded_topic_list_custom_field(field)

add_to_serializer(:topic_list_item, field.to_sym) { object.custom_fields[field] }

add_to_serializer(:topic_view, field.to_sym) { object.topic.custom_fields[field] }

add_to_serializer(:search_topic_list_item, field.to_sym) { object.custom_fields[field] }

لقد أضفت جزءًا من التعليمات البرمجية إلى المكون الإضافي لإرجاع الحقول المخصصة في قائمة البحث، ولكن حدث استثناء. التعليمات البرمجية المضافة هي:

add_to_serializer(:search_topic_list_item, field.to_sym) { object.custom_fields[field] }

خطأ:

HasCustomFields::NotPreloadedError (Attempted to access the non preloaded custom field 'video_url' on the 'Topic' class. This is disallowed to prevent N+1 queries.) app/models/concerns/has_cus

هل واجه أي شخص هذه المشكلة من قبل؟ سأكون ممتنًا جدًا لأي مساعدة.