Create report of all items that are missing holding institutions
This query does the trick (588 results), but it would be nice to figure out how to do this using activerecord:
SELECT items.record_id from items
LEFT JOIN holding_institutions_items hii ON hii.item_id = items.id
WHERE hii.holding_institution_id IS NULL
Seamus figured out the Activerecord way:
Item.includes(:holding_institutions).where(holding_institutions: {id: nil})
and this one is a bit faster
Item.left_joins(:holding_institutions).where(holding_institutions: {id: nil})
Edited by Sean Purcell