lib/active_storage/attached/model.rb in activestorage-7.1.2 vs lib/active_storage/attached/model.rb in activestorage-7.1.3

- old
+ new

@@ -114,11 +114,14 @@ has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record, inverse_of: :record, dependent: :destroy, strict_loading: strict_loading has_one :"#{name}_blob", through: :"#{name}_attachment", class_name: "ActiveStorage::Blob", source: :blob, strict_loading: strict_loading scope :"with_attached_#{name}", -> { if ActiveStorage.track_variants - includes("#{name}_attachment": { blob: { variant_records: { image_attachment: :blob } } }) + includes("#{name}_attachment": { blob: { + variant_records: { image_attachment: :blob }, + preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } } + } }) else includes("#{name}_attachment": :blob) end } @@ -201,10 +204,13 @@ has_many :"#{name}_attachments", -> { where(name: name) }, as: :record, class_name: "ActiveStorage::Attachment", inverse_of: :record, dependent: :destroy, strict_loading: strict_loading has_many :"#{name}_blobs", through: :"#{name}_attachments", class_name: "ActiveStorage::Blob", source: :blob, strict_loading: strict_loading scope :"with_attached_#{name}", -> { if ActiveStorage.track_variants - includes("#{name}_attachments": { blob: { variant_records: { image_attachment: :blob } } }) + includes("#{name}_attachments": { blob: { + variant_records: { image_attachment: :blob }, + preview_image_attachment: { blob: { variant_records: { image_attachment: :blob } } } + } }) else includes("#{name}_attachments": :blob) end }