This isn't so much a solution for the achievement as Pingy's video (and the walkthrough) does a fantastic job of showing how to earn most of the hats. This is just a video for the hat on 8-7 - the Fat Cake level that seems to be giving a few people problems.
I tried the level with Pingy's method a few dozen times and couldn't manage it, but with this solution, I managed to get to the hat location several times pretty easily (DVR didn't capture me getting the hat, so I went and did it again for this solution - it's just in front of the two rotation switches you see me hit midway through the video - you'll see it when you get there.
You want to bounce off the trampoline and boost a bit so you'll hit the rotation switch. Immediately start boosting left otherwise you won't have enough momentum to get to the S-bend bit. You want to grab the cake to protect you from the wall - but don't worry if you miss the cake after hitting the first rotation switch, you could still make it. When I got the hat, I managed to drop just in front of the spiked wall without the cake protection - I just didn't manage it for the video. Follow the bendy bit whichever way you get there, hit the rotation switch in the middle and then drop out of the bendy bit - you won't die on the drop, you'll land on the roof. Boost up to the cake, drop down and break the ceiling, then wander left to get your hat. Finish the level, or quit out, whatever you need to do.
Hope it helps some of you!