Created
September 5, 2016 13:18
-
-
Save dereknguyen269/8f4dbde014ec713bf3ff7f235a946e12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
account = Account.find_by_user_id(5) | |
#account.balance is still 100 | |
#item.price is 80 | |
if account.balance >= item.price | |
#it's good, allow user to buy this item | |
account.balance = account.balance - item.price | |
#account.balance is now 20 | |
account.save | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment