提交 94315290 编写于 作者: K kami-zh

Change Active Storage destroy callbacks

There is concern that only blob are deleted depending on
the `before_destroy` definition order which throws abort.
上级 428939be
* 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,
......
......@@ -44,7 +44,7 @@ def #{name}=(attachable)
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 @@ def #{name}=(attachables)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册