It never fails that when I am writing a story, other ideas for an even better tale come along. The temptation is to drop your current project and lay down tracks for the new idea. Some people can do this and manage to be productive. I can't. It reminds me of that old saying "The grass is always greener on the other side of the fence." We all know from life experience that it never is.
If I give into the base temptation of shirking my responsibility to my present piece of writing, and going off on what turns out to be a fool's literary crusade, I find it is like eating cotton candy; sweet at first, but it dissolves very quickly after a few bites. Well that may not the best analogy, but it's the best I can do off the top of my head. Basically, with very few exceptions, cheating on my current story with a fresher, sexier idea never works out. So, here is my solution.
First, before I reveal the magic, let me say that I used to solve the dilemma by writing that story flash down in one of my story idea files. But, I find when I do that, I grow to hate my current project even more and tend to rush through it, thus not giving it the attention it deserves in order to get to the other idea.
Again, here is what I propose. When you get a brilliant inspiration for another yarn, try seeing if and how it fits into the story you are already working on. You never know, the incorporation of this idea might lead your piece in strange and wonderful directions. If it doesn't, then oh well, you can squirrel it away for later. Or, perhaps, scrap it entirely since after thinking about it and trying to implement it, you find it wasn't all that inspired after all.