aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/attached
diff options
context:
space:
mode:
authorkami-zh <hiroki.zenigami@gmail.com>2018-01-09 12:28:38 +0900
committerkami-zh <hiroki.zenigami@gmail.com>2018-01-09 22:47:02 +0900
commit9431529011b0057bb8833dc16726714166547a28 (patch)
tree8739020c3531f525d4b2492ad98db2fa563e3b95 /activestorage/lib/active_storage/attached
parent428939be9f954d39b0c41bc53d85d0d106b9d1a1 (diff)
downloadrails-9431529011b0057bb8833dc16726714166547a28.tar.gz
rails-9431529011b0057bb8833dc16726714166547a28.tar.bz2
rails-9431529011b0057bb8833dc16726714166547a28.zip
Change Active Storage destroy callbacks
There is concern that only blob are deleted depending on the `before_destroy` definition order which throws abort.
Diffstat (limited to 'activestorage/lib/active_storage/attached')
-rw-r--r--activestorage/lib/active_storage/attached/macros.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activestorage/lib/active_storage/attached/macros.rb b/activestorage/lib/active_storage/attached/macros.rb
index 442dcabd0c..c51efa9d6b 100644
--- a/activestorage/lib/active_storage/attached/macros.rb
+++ b/activestorage/lib/active_storage/attached/macros.rb
@@ -44,7 +44,7 @@ module ActiveStorage
scope :"with_attached_#{name}", -> { includes("#{name}_attachment": :blob) }
if dependent == :purge_later
- before_destroy { public_send(name).purge_later }
+ after_destroy_commit { public_send(name).purge_later }
end
end
@@ -89,7 +89,7 @@ module ActiveStorage
scope :"with_attached_#{name}", -> { includes("#{name}_attachments": :blob) }
if dependent == :purge_later
- before_destroy { public_send(name).purge_later }
+ after_destroy_commit { public_send(name).purge_later }
end
end
end