Skip to content

Instantly share code, notes, and snippets.

@dpaola2
Created September 10, 2015 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpaola2/5e07a1efd44bad662f4c to your computer and use it in GitHub Desktop.
Save dpaola2/5e07a1efd44bad662f4c to your computer and use it in GitHub Desktop.
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