aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_storage')
-rw-r--r--lib/active_storage/attached/many.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/active_storage/attached/many.rb b/lib/active_storage/attached/many.rb
index 704369ba89..ea4aade5d7 100644
--- a/lib/active_storage/attached/many.rb
+++ b/lib/active_storage/attached/many.rb
@@ -13,9 +13,9 @@ class ActiveStorage::Attached::Many < ActiveStorage::Attached
# Associates one or several attachments with the current record, saving
# them to the database.
def attach(*attachables)
- record.public_send("#{name}_attachments=", attachments | Array(attachables).flat_map do |attachable|
- ActiveStorage::Attachment.create!(record: record, name: name, blob: create_blob_from(attachable))
- end)
+ attachables.flatten.collect do |attachable|
+ attachments.create!(name: name, blob: create_blob_from(attachable))
+ end
end
# Checks the presence of attachments.