aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage/attached/macros.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-07-24 15:36:30 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2017-07-24 15:36:33 -0500
commit92536c08d53c5d54f6c526bfdc5d854dd00a7a88 (patch)
treebce150413987c2a3e11c9fdb0707057e211e0f00 /lib/active_storage/attached/macros.rb
parent87cb0063742f9d5672f69f623be8fe1dee79b223 (diff)
downloadrails-92536c08d53c5d54f6c526bfdc5d854dd00a7a88.tar.gz
rails-92536c08d53c5d54f6c526bfdc5d854dd00a7a88.tar.bz2
rails-92536c08d53c5d54f6c526bfdc5d854dd00a7a88.zip
Document the rest of lib
Diffstat (limited to 'lib/active_storage/attached/macros.rb')
-rw-r--r--lib/active_storage/attached/macros.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/active_storage/attached/macros.rb b/lib/active_storage/attached/macros.rb
index 11f88f16e5..89297e5bdf 100644
--- a/lib/active_storage/attached/macros.rb
+++ b/lib/active_storage/attached/macros.rb
@@ -9,6 +9,15 @@ module ActiveStorage::Attached::Macros
# There is no column defined on the model side, Active Storage takes
# care of the mapping between your records and the attachment.
#
+ # Under the covers, this relationship is implemented as a `has_one` association to a
+ # `ActiveStorage::Attachment` record and a `has_one-through` association to a
+ # `ActiveStorage::Blob` record. These associations are available as `avatar_attachment`
+ # and `avatar_blob`. But you shouldn't need to work with these associations directly in
+ # most circumstances.
+ #
+ # The system has been designed to having you go through the `ActiveStorage::Attached::One`
+ # proxy that provides the dynamic proxy to the associations and factory methods, like `#attach`.
+ #
# If the +:dependent+ option isn't set, the attachment will be purged
# (i.e. destroyed) whenever the record is destroyed.
def has_one_attached(name, dependent: :purge_later)
@@ -38,6 +47,15 @@ module ActiveStorage::Attached::Macros
#
# Gallery.where(user: Current.user).with_attached_photos
#
+ # Under the covers, this relationship is implemented as a `has_many` association to a
+ # `ActiveStorage::Attachment` record and a `has_many-through` association to a
+ # `ActiveStorage::Blob` record. These associations are available as `photos_attachments`
+ # and `photos_blobs`. But you shouldn't need to work with these associations directly in
+ # most circumstances.
+ #
+ # The system has been designed to having you go through the `ActiveStorage::Attached::Many`
+ # proxy that provides the dynamic proxy to the associations and factory methods, like `#attach`.
+ #
# If the +:dependent+ option isn't set, all the attachments will be purged
# (i.e. destroyed) whenever the record is destroyed.
def has_many_attached(name, dependent: :purge_later)