@orders.closed_today is an array of all orders closed for today.
How can I list get all the items for this?
i.e. @items = @orders.closed_today.items
Update
Reports html
<% @items = Item.in_orders(@orders.closed_today) %>
Items model
scope :in_orders, lambda { |orders| where('order_id is in (?)', orders.map(&:id).join(',') ) }
Simple: map the items.
That will give you:
To get unique items:
This is not a sustainable way of fetching related objects; beware N+1 performance problems.
More generally, you should probably do something like this:
and just call: