I’m confused as to why that Rails Guide mentions using flash values in render, since they only appear to work in redirect_to at the moment. I think you’ll find your approach works if you put a flash.now[:alert] = 'Alert message!' before your render method call.
Edit: this is a flaw in the guides that will be fixed, you should use the separate method call to set the flash prior to calling render.