Rails find record with zero has_many records associated [duplicate]

Bah, found it here: https://stackoverflow.com/a/5570221/417872

City.includes(:photos).where(photos: { city_id: nil })

Leave a Comment