我有一个Customer
模型,每个客户都有很多工作:
class Customer < ActiveRecord::Base
has_many :jobs
end
class Job < ActiveRecord::Base
belongs_to :customer
def self.unbilled
finished.uninvoiced # these are other scopes on Job
end
end
如何定义一个范围,Customer
该范围将返回所有未开票工作的客户列表?