I have a Box, which has many Compartments which contain many Items which belong to a Category. Items are polymorphic (:itemable) as they can belong to Boxes without Compartments - this might be my difficulty.
I can call all Items back for all Boxes in the DB, in the Box controller with:
@category_items = Item.includes(:category).group("categories.name").sum("quantity * value")
but how can I filter these down to those that belong only to the current Box id?