Skip to content

Instantly share code, notes, and snippets.

@xhoy
Created January 20, 2015 13:30
Show Gist options
  • Save xhoy/aab58a5fdcf18b90bd56 to your computer and use it in GitHub Desktop.
Save xhoy/aab58a5fdcf18b90bd56 to your computer and use it in GitHub Desktop.
callback issue
InvoicePayment.create()
byebug =>
invoice_payments.size => 1
(byebug) id => 2861
(byebug) Invoice.find(2861).invoice_payments.size => 2
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