Last active
August 29, 2016 16:00
-
-
Save briu/7bd81738afe6c3506a32f51b8d2290ed to your computer and use it in GitHub Desktop.
interview
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
class Finance < ActiveRecord::Base | |
validate :check_amount | |
def check_amount | |
errors.add(:check_amount, 'quantity limit over!') if amount > 100 | |
end | |
end | |
first = Finance.first | |
second = Finance.last | |
# puts second.amount | |
# => 90 | |
ActiveRecord::Base.transaction do | |
first.update(amount: 500) | |
second.update(amount: 80) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment