From efa8779c659221b8e4fa9a154b10f4aa15a3994a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 23 Jul 2017 17:31:02 -0500 Subject: Fix attaching Can use the associations now --- lib/active_storage/attached/many.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/active_storage') 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. -- cgit v1.2.3