Created
January 20, 2015 13:30
-
-
Save xhoy/aab58a5fdcf18b90bd56 to your computer and use it in GitHub Desktop.
callback issue
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
InvoicePayment.create() | |
byebug => | |
invoice_payments.size => 1 | |
(byebug) id => 2861 | |
(byebug) Invoice.find(2861).invoice_payments.size => 2 | |
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 InvoicePayment < ActiveRecord::Base | |
belongs_to :invoice | |
after_save :{invoice.update_payment} | |
end | |
class Invoice < ActiveRecord::Base | |
def checkpayments | |
byebug => see console | |
invoice_payments.map(&:amount).sum - price == 0 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment