Story of Lord Shiva’s Atmalingam and Ravana tells us how Lord Ganesha has played the spoil sport to prevent Ravana becoming more powerful..
Once Ravana by his musical skill pleased Lord Shiva, Blessing him Lord Shiva gave a Shiva Linga (Athma Linga)and asked Ravana to take it Sri Lanka and preserve it there. He told Ravana that if that Shiva Linga reaches Sri Lanka, no body can win over Ravana.
But he also told that he should never keep that Shiva Linga down on earth at any other spot while on his way. When Ravana reached Gokarna (A place in Karnataka) he wanted very badly to answer natures call, Ganapathi appeared there as Brahmin boy and agreed to hold the Shiva Linga for some time. He also told Ravana that if he does not come back
by the stipulated time, he would keep the Shiva Linga there and go away.
Lord Ganapathi delayed the coming back of Ravana and kept the Shiva Linga there and vanished. That place is called Gokarna. This effectively prevented Ravana to be ever victorious.