mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Wrap account update in transaction (#985)
This commit is contained in:
parent
744ffb68aa
commit
37d5c149ba
1 changed files with 4 additions and 2 deletions
|
@ -40,8 +40,10 @@ class AccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@account.update! account_params.except(:accountable_type, :balance)
|
Account.transaction do
|
||||||
@account.update_balance!(account_params[:balance]) if account_params[:balance]
|
@account.update! account_params.except(:accountable_type, :balance)
|
||||||
|
@account.update_balance!(account_params[:balance]) if account_params[:balance]
|
||||||
|
end
|
||||||
@account.sync_later
|
@account.sync_later
|
||||||
redirect_back_or_to account_path(@account), notice: t(".success")
|
redirect_back_or_to account_path(@account), notice: t(".success")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue