aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-07-24 14:35:36 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2017-07-24 14:35:36 -0500
commit3eb8c89c0410fac34aefc8b89b8c6b5901c39415 (patch)
treefeab05c7ed4a9ee67ada5803da2674c27f9172ea /lib
parent20effee5671d76875c050e3d9e91ff60fa181a91 (diff)
downloadrails-3eb8c89c0410fac34aefc8b89b8c6b5901c39415.tar.gz
rails-3eb8c89c0410fac34aefc8b89b8c6b5901c39415.tar.bz2
rails-3eb8c89c0410fac34aefc8b89b8c6b5901c39415.zip
Fix blob associations
cc @javan
Diffstat (limited to 'lib')
-rw-r--r--lib/active_storage/attached/macros.rb4
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) }