diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-09 18:48:26 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2017-07-23 21:17:17 +0200 |
commit | 5963766d840ddcdb577a1bd10eb1491a4ef9132f (patch) | |
tree | e6cba96cac8865435486ba08a1a5fc0f04d6e9f7 /lib/active_storage/attached/many.rb | |
parent | 4efbeaeaab72be070e203f39726b37703c1db1fa (diff) | |
download | rails-5963766d840ddcdb577a1bd10eb1491a4ef9132f.tar.gz rails-5963766d840ddcdb577a1bd10eb1491a4ef9132f.tar.bz2 rails-5963766d840ddcdb577a1bd10eb1491a4ef9132f.zip |
Explore regular polymorphic associations rather than record_gid
Diffstat (limited to 'lib/active_storage/attached/many.rb')
-rw-r--r-- | lib/active_storage/attached/many.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/active_storage/attached/many.rb b/lib/active_storage/attached/many.rb index 99d980196a..129f166776 100644 --- a/lib/active_storage/attached/many.rb +++ b/lib/active_storage/attached/many.rb @@ -7,14 +7,14 @@ class ActiveStorage::Attached::Many < ActiveStorage::Attached # You don't have to call this method to access the attachments' methods as # they are all available at the model level. def attachments - @attachments ||= ActiveStorage::Attachment.where(record_gid: record.to_gid.to_s, name: name) + @attachments ||= record.public_send("#{name}_attachments") end # Associates one or several attachments with the current record, saving # them to the database. def attach(*attachables) @attachments = attachments | Array(attachables).flatten.collect do |attachable| - ActiveStorage::Attachment.create!(record_gid: record.to_gid.to_s, name: name, blob: create_blob_from(attachable)) + ActiveStorage::Attachment.create!(record: record, name: name, blob: create_blob_from(attachable)) end end |