diff options
Diffstat (limited to 'lib/active_storage/attached/macros.rb')
-rw-r--r-- | lib/active_storage/attached/macros.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/active_storage/attached/macros.rb b/lib/active_storage/attached/macros.rb index 54c2731c08..11f88f16e5 100644 --- a/lib/active_storage/attached/macros.rb +++ b/lib/active_storage/attached/macros.rb @@ -18,7 +18,7 @@ module ActiveStorage::Attached::Macros end has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record - has_one :"#{name}_blob", through: :"#{name}_attachment" + has_one :"#{name}_blob", through: :"#{name}_attachment", class_name: "ActiveStorage::Blob", source: :blob if dependent == :purge_later before_destroy { public_send(name).purge_later } @@ -47,7 +47,7 @@ module ActiveStorage::Attached::Macros end has_many :"#{name}_attachments", -> { where(name: name) }, as: :record, class_name: "ActiveStorage::Attachment" - has_many :"#{name}_blobs", through: :"#{name}_attachments" + has_many :"#{name}_blobs", through: :"#{name}_attachments", class_name: "ActiveStorage::Blob", source: :blob scope :"with_attached_#{name}", -> { includes("#{name}_attachments": :blob) } |