The Internet offers conflicting advice on how to resist temptations. For example, this article stresses the importance of willpower:
Animals appear to obey their appetites in the moment; people — at least, adult people — can say “no” to what may be immediately tempting, for the sake of the greater material rewards or moral virtue that come from reining ourselves in. Yet most of us fail to rein ourselves in as much as we would like, at least in some part of our lives. In one way or another, failures of willpower are at the root of countless problems in our society — obesity, addictions, violence, relationship problems, consumer debt, to name just a few.
On the other hand, this book says:
Willpower doesn't work. ... Clearly, the research on willpower explains human behavior. But only on the surface level. The very fact that willpower is required comes from several fundamental sources:
You don’t know what you want, and are thus internally conflicted.
Your desire (your why) for your goals isn’t strong enough.
You aren’t invested in yourself and your dreams.
Your environment opposes your goal.
Once these four principles are aligned within yourself, the internal debate is over.
What's the current scientific view on how to avoid succumbing to temptations? What techniques are considered best? I'd be especially grateful for references to good-quality science-based books or articles about this matter.