Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Skip unnecessary sync when account balance unchanged on update (#1040)

Jeff Rowbergb1b2793e43e9
diff --git a/app/controllers/concerns/accountable_resource.rb b/app/controllers/concerns/accountable_resource.rb
index 1b8bbf6d23..007a5f33a9 100644
--- a/app/controllers/concerns/accountable_resource.rb
+++ b/app/controllers/concerns/accountable_resource.rb
@@ -41,15 +41,14 @@ module AccountableResource
end
def update
- # Handle balance update if provided
- if account_params[:balance].present?
+ # Handle balance update if the value actually changed
+ if account_params[:balance].present? && account_params[:balance].to_d != @account.balance
result = @account.set_current_balance(account_params[:balance].to_d)
unless result.success?
@error_message = result.error_message
render :edit, status: :unprocessable_entity
return
end
- @account.sync_later
end
# Update remaining account attributes