You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have an after commit hook on a destroy action on a model it will never be called when the model uses permanent records.
class TestModel < ActiveRecord::Base
after_commit :commit_delete, on: :destroy
def commit_delete
puts "Commiting Delete"
end
end
test = TestModel.create
test.destroy
=> true
This is problematic when deleting files with attachments in paperclip as paperclip relies on after_commit on delete to remove files from the filesystem.
The text was updated successfully, but these errors were encountered:
I've also noticed that my after_save callback does get called after I delete a record.
I think the after_commit, after_save, etc callbacks detect when some record has changed, and then fires or not accordingly. So when permanent_records updates a record's deleted_at field, that looks like a modified record and thus after_save fires.
I think those AR callback methods will need to be monkey-patched to get the right behavior in these cases.
If I have an after commit hook on a destroy action on a model it will never be called when the model uses permanent records.
This is problematic when deleting files with attachments in paperclip as paperclip relies on after_commit on delete to remove files from the filesystem.
The text was updated successfully, but these errors were encountered: