I was lamenting fruit flies on Twitter several years ago, and Teacher Tom stepped in to save me.
Seattle had decreed that all food and yard waste needed to go in the compost bin rather than the garbage. This was a change I could get behind as an eco-friendly ideal.
But the small kitchen waste bin the city handed out for collecting our kitchen scraps had two distinct problems: The smell of rotting food seeped out into our kitchen, and fruit flies gathered to feast. It didn't seem to matter how often we emptied the little container, and we even bought a fancier one with a locking lid and filter, with no accompanying improvement.