Module: SimpleActiveStorage::Attached::Many
- Defined in:
- lib/simple_active_storage/attached.rb
Instance Method Summary collapse
-
#attach(*attachables) ⇒ Object
检查过滤掉已经存在的.
Instance Method Details
#attach(*attachables) ⇒ Object
检查过滤掉已经存在的
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/simple_active_storage/attached.rb', line 7 def attach(*attachables) record.try(:before_active_storage_attach,attachables) # remove duplicate attachments signed_ids = .map(&:signed_id) blobs = attachables.map{|attachable| create_blob_from attachable}.compact filtered_blobs = blobs.find_all{|blob| !signed_ids.include?(blob.signed_id) } result = super(*filtered_blobs) record.try(:after_active_storage_attach,{name: name, attachments: }) result end |