Topic: [SOLVED] Scope users by "late" if invoice not paid
So I have 3 models:
#User.rb has_many :contracts has_many :invoices, :through => :contracts #Invoice.rb belongs_to :contract has_one :user, :through => :contract #Contract.rb belongs_to :user has_many :invoices
The "Contract" is simply a way of linking users and invoices together.
My question is, I'm wanting to find users that have past-due invoices. So, if invoice_total is greater than zero, and the invoice_due_date is past, I want to find the users that are related to that invoice.
#User.rb scope :late_payment, where()
How would I do this efficiently?
Last edited by wesf90 (2012-04-30 09:16:31)