1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #31652 from kami-zh/activestorage-callbacks

Change Active Storage destroy callbacks
This commit is contained in:
George Claghorn 2018-01-09 10:02:22 -05:00 committed by GitHub
commit baa88b8ddf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -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,

View file

@ -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