diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-23 17:31:02 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-23 17:31:02 -0500 |
commit | efa8779c659221b8e4fa9a154b10f4aa15a3994a (patch) | |
tree | 0977585e2e82d1198205168757372590480e6603 /lib | |
parent | 54b17a1c8323c6ec3a7d6e521179ef36d396d285 (diff) | |
download | rails-efa8779c659221b8e4fa9a154b10f4aa15a3994a.tar.gz rails-efa8779c659221b8e4fa9a154b10f4aa15a3994a.tar.bz2 rails-efa8779c659221b8e4fa9a154b10f4aa15a3994a.zip |
Fix attaching
Can use the associations now
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_storage/attached/many.rb | 6 |
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. |