Skip to content

Instantly share code, notes, and snippets.

@dpaola2 dpaola2/transfer.rb
Created Sep 10, 2015

Embed
What would you like to do?
class Account
...
end
class Transfer
def self.exec(acct1, acct2, amt)
Transaction.begin do
acct1.balance -= amt
acct2.balance += amt
acct1.save!
acct2.save!
end
end
end
Transfer.exec(Account.find(1), Account.find(2), 500.00)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.