@ orders.closed_today is an array of all orders closed for today.
How can I get all the items for this?
i.e.
@Itms = @order.closed_tayday.itms
update reports html
& lt; % @items = Item.in_orders (@ Orders.closed_today)%> item model
scope: in_orders, lambda {| Order | Where ('in order_id (?)', Orders.map (& id) .join (','))}
Simple: Map items.
@items = @order.closed_tod.l (: include = & gt;: item) .map (& amp;; item) This will give you:
= & gt; [[Item 1, Item 2], [Item 2, Item 3]] To get exclusive items:
@order.close_toded. L (: included =>: items) .map (and: items). Flaten.Yinek It is not a permanent way of bringing related items; N + 1 Performance Problems Be Careful
More generally, you should do something like this:
area of square item: closed_tode, joins (: order) & amp; And just call:
Item.closed_today
Comments
Post a Comment