Skip to content

Instantly share code, notes, and snippets.

@AJFaraday
Last active December 17, 2015 11:39
Show Gist options
  • Save AJFaraday/5603980 to your computer and use it in GitHub Desktop.
Save AJFaraday/5603980 to your computer and use it in GitHub Desktop.
class Event < ActiveRecord
has_many :charges do
def self.total
self.collect{|charge|charge.total}.sum
end
end
has_many :transactions do
def self.total
self.collect{|charge|charge.total}.sum
end
end
def underpaid?
self.charges.total > self.transactions.total
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment