0
을 통해 내가 가지고있는 다음과 같은 모델 :Mongoid, 복잡한 쿼리, has_many 비슷한 :
class Company
# ...
has_many :invoices
end
class Invoice
# ...
belongs_to :company
has_many :items
field :type, String
scope :expense, where(type: 'expense')
scope :income, where(type: 'income')
end
class Item
# ...
belongs_to :invoice
end
문제는 주어진 회사의 모든 income
아이템을 취득하는 방법은? 어떤 차이를 만들 수 없습니다 포함 된 관계를 사용 company.items.expense