diff options
author | George Claghorn <george@basecamp.com> | 2017-11-14 10:42:10 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2017-11-14 10:42:51 -0500 |
commit | 499a4164ce9816c4913bf3db14787ea99ef2c266 (patch) | |
tree | c8cd465cc9533b62751a032aae8fba40cf831499 /activestorage/lib/active_storage/attached/many.rb | |
parent | 82022bd205db20cb9c947f72aba89c8624c8745d (diff) | |
download | rails-499a4164ce9816c4913bf3db14787ea99ef2c266.tar.gz rails-499a4164ce9816c4913bf3db14787ea99ef2c266.tar.bz2 rails-499a4164ce9816c4913bf3db14787ea99ef2c266.zip |
Introduce ActiveStorage::Attached::{One,Many}#detach
Diffstat (limited to 'activestorage/lib/active_storage/attached/many.rb')
-rw-r--r-- | activestorage/lib/active_storage/attached/many.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activestorage/lib/active_storage/attached/many.rb b/activestorage/lib/active_storage/attached/many.rb index 1e0657c33c..0b3400bccf 100644 --- a/activestorage/lib/active_storage/attached/many.rb +++ b/activestorage/lib/active_storage/attached/many.rb @@ -13,7 +13,6 @@ module ActiveStorage end # Associates one or several attachments with the current record, saving them to the database. - # Examples: # # document.images.attach(params[:images]) # Array of ActionDispatch::Http::UploadedFile objects # document.images.attach(params[:signed_blob_id]) # Signed reference to blob from direct upload @@ -36,6 +35,11 @@ module ActiveStorage attachments.any? end + # Deletes associated attachments without purging them, leaving their respective blobs in place. + def detach + attachments.destroy_all if attached? + end + # Directly purges each associated attachment (i.e. destroys the blobs and # attachments and deletes the files on the service). def purge |