views:

22

answers:

1

How do you build a model with the following associations (i tried but couldn't get it to work):

each Order has: a Customer, a SalesRep, many OrderLine that each has an item.

I tried: when I do: Customer.all(Customer.orders.order_lines.item.sku.like => "%BLUE%") the output is :[]
instead of: '[#<"Customer @id=1 @name="Dan Kubb">]'

When I delete SalesRep: it works.

Customer
has n, :orders
has n, :items, :through => :order

SalesRep
has n, :orders
has n, :items, :through => :order

Order
belongs_to :customer
belongs_to :technician
has n, :order_lines
has n, :items, :through => :order_line

OrderLine
belongs_to :order
belongs_to :item

Item
has n, :order_lines