diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-01-09 10:02:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-09 10:02:22 -0500 |
commit | baa88b8ddff59b10b8e98eeee7503e2416da8abe (patch) | |
tree | 8739020c3531f525d4b2492ad98db2fa563e3b95 | |
parent | 428939be9f954d39b0c41bc53d85d0d106b9d1a1 (diff) | |
parent | 9431529011b0057bb8833dc16726714166547a28 (diff) | |
download | rails-baa88b8ddff59b10b8e98eeee7503e2416da8abe.tar.gz rails-baa88b8ddff59b10b8e98eeee7503e2416da8abe.tar.bz2 rails-baa88b8ddff59b10b8e98eeee7503e2416da8abe.zip |
Merge pull request #31652 from kami-zh/activestorage-callbacks
Change Active Storage destroy callbacks
-rw-r--r-- | activestorage/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activestorage/lib/active_storage/attached/macros.rb | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index 9ce177b462..5e01297fc1 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,3 +1,9 @@ +* Use `after_destroy_commit` instead of `before_destroy` for purging + attachments when a record is destroyed. + + *Hiroki Zenigami* + + * Force `:attachment` disposition for specific, configurable content types. This mitigates possible security issues such as XSS or phishing when serving them inline. A list of such content types is included by default, 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 |