1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activestorage/lib
Abhay Nikam 15d5b7589a Fixes ActiveStorage#has_many_attached re-creating destroyed attachment
fixes #41862

ActiveStorage#has_many_attached with `config.active_storage.replace_on_assign_to_many = false`
flag set to flase always appends new attachments to the association.
As mentioned in the issue, if you use nested attributes along with
flag disabled and mark some of the attachment to be `destroyed?`.
The attachment is destroyed but get re-created without blob upload.
This also results in `ActiveStorage#purge_job` failing with rollback.

This PR intends to resolve the issue by checking if the attachment is
persisted when `#save` is invoked. Only persisted and attachment
records are saved which patches the issues.
2021-05-14 20:11:01 +05:30
..
active_storage Fixes ActiveStorage#has_many_attached re-creating destroyed attachment 2021-05-14 20:11:01 +05:30
tasks Add foreign key to active_storage_attachments for blob_id via new migration 2019-01-16 13:13:23 +00:00
active_storage.rb Improve Fixture support for Active Storage (#41065) 2021-01-24 11:10:30 +01:00