To elaborate, they don't damage your stomach via contact, they inhibit COX which is an enzyme that contributes to gastric mucosal protection and regeneration.
So it doesn't matter whether you eat with them or not, largely, unless what you're eating with them is an antacid or proton pump inhibitor.