Files
sure/app/jobs/destroy_job.rb
sentry[bot] 117ab2b45f refactor(accounts): Improve destroy_later atomicity and add controller error handling (#1395)
* refactor(accounts): Improve destroy_later atomicity and add controller error handling

* Address PR comment

---------

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-04-07 15:53:25 +02:00

11 lines
271 B
Ruby

class DestroyJob < ApplicationJob
queue_as :low_priority
self.enqueue_after_transaction_commit = :never
def perform(model)
model.destroy
rescue => e
model.update!(scheduled_for_deletion: false) # Let's the user try again by resetting the state
end
end