How do you handle temptations in your relationship?

Lord, lead me not into temptation. I can find it myself :-) A person in a marriage or a long-term relationship who claims to never have been tempted nor asked a what-if is either a hermit, blind, or a liar. The nature of monogamy in itself requires an effort to remain faithful to one person, and this is not by accident. We are seeing and feeling creatures so any kind of human engagement could progress into something if left unchecked. I am a little older and have gone through a fair share of relationships and attractions so I want to say I know how to steer clear of attractions when they come close to crossing a line. But I am also not infallible, especially with the handicap of a firecracker in my chest. I've hurt and irrevocably harmed partners in the past so I know that regret is often a heavier burden than the restraint to act on a passing attraction. And they do pass, eventually, no matter how worked up you've gotten in your head. Lately I've tried to look inward when faced with such situations. What is in me that is being fed by this external stimulus, or what in my relationship needs to be renewed? I've gotten to the point of actually being able to discuss temptations with partners, but that only comes with solid trust and a shared goal to maintain a healthy relationship.
One of my favorite sayings is a Greek proverb, roughly translated as "The third person can only fit in the space between the first two."
Don't fool yourself that you can be in a long-term relationship without working on these spaces. Relationships probably require more work than a full-time job because you're engaged in it even in your sleep. Keep busy with the relationship you value. With all the other time you have, keep emotionally and intellectually engaged. Personally I find that if you effectively employ all your passions, there isn't much left for it to stray. :-)