Skip to content

Instantly share code, notes, and snippets.

@francois
Created November 18, 2008 03:57
Show Gist options
  • Save francois/26043 to your computer and use it in GitHub Desktop.
Save francois/26043 to your computer and use it in GitHub Desktop.
class SplitsController < ApplicationController
def update
transfers = []
Transfer.transaction do
SyncEnumerator.new(params[:account_id], params[:amount]).each do |account_id, amount|
next if amount.blank?
transfers << transfer = current_family.transfers.build(:debit_account => current_family.accounts.find(account_id), :amount => amount)
transfer.bank_transactions << bank_transaction
transfer.save!
end
end
flash[:notice] = "#{transfers.length} transferts fûrent créés"
redirect_to bank_transactions_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment