mirror of
https://github.com/we-promise/sure.git
synced 2026-06-04 10:19:03 +00:00
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>
This commit is contained in:
@@ -113,8 +113,13 @@ class AccountsController < ApplicationController
|
||||
if @account.linked?
|
||||
redirect_to account_path(@account), alert: t("accounts.destroy.cannot_delete_linked")
|
||||
else
|
||||
@account.destroy_later
|
||||
redirect_to accounts_path, notice: t("accounts.destroy.success", type: @account.accountable_type)
|
||||
begin
|
||||
@account.destroy_later
|
||||
redirect_to accounts_path, notice: t("accounts.destroy.success", type: @account.accountable_type)
|
||||
rescue => e
|
||||
Rails.logger.error "Failed to schedule account #{@account.id} for deletion: #{e.message}"
|
||||
redirect_to accounts_path, alert: t("accounts.destroy.failed")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user