mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Enable syncing all accounts in one click (#948)
* Enable syncing all accounts on one click * Remove argument to sync_later method call * Add partial for sync all accounts button * Redirect back if possible when syncing all accounts
This commit is contained in:
parent
48092cb704
commit
cc6bf6e961
7 changed files with 33 additions and 0 deletions
|
@ -69,6 +69,22 @@ class AccountsController < ApplicationController
|
|||
redirect_to account_path(@account), notice: t(".success")
|
||||
end
|
||||
|
||||
def sync_all
|
||||
synced_accounts_count = 0
|
||||
Current.family.accounts.each do |account|
|
||||
next unless account.can_sync?
|
||||
|
||||
account.sync_later
|
||||
synced_accounts_count += 1
|
||||
end
|
||||
|
||||
if synced_accounts_count > 0
|
||||
redirect_back_or_to accounts_path, notice: t(".success", count: synced_accounts_count)
|
||||
else
|
||||
redirect_back_or_to accounts_path, alert: t(".no_accounts_to_sync")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue