diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-24 14:35:36 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-24 14:35:36 -0500 |
commit | 3eb8c89c0410fac34aefc8b89b8c6b5901c39415 (patch) | |
tree | feab05c7ed4a9ee67ada5803da2674c27f9172ea /lib/active_storage | |
parent | 20effee5671d76875c050e3d9e91ff60fa181a91 (diff) | |
download | rails-3eb8c89c0410fac34aefc8b89b8c6b5901c39415.tar.gz rails-3eb8c89c0410fac34aefc8b89b8c6b5901c39415.tar.bz2 rails-3eb8c89c0410fac34aefc8b89b8c6b5901c39415.zip |
Fix blob associations
cc @javan
Diffstat (limited to 'lib/active_storage')
-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) } |