A friend of mine once told me "you are more productive than you think you are". What he meant was that good ideas strike at all sorts of random times. His method was to carry a notebook and pencil with him everywhere to note them down. With the idea recorded (whether a concept, a breakdown, a synth line, whatever...) you can return to the studio later to make it happen.
The notebook doesn't really work for me but my phone can record voice memos, and that does. I tend to sing or hum lines and rhythms into it.
I do keep a notebook by my bed for the creative ideas that strike just before going to sleep. This happens pretty often in my experience - it's an altered consciousness thing. Sometimes I'll get up there and then to work on the idea.
Finally, talking of altered consciousness, I'm surprised nobody has yet mentioned that there are (so I'm told) certain substances that can help with generating creative ideas. It goes without saying that it would be very very bad to become dependent on anything unhealthy in order to create music
But seeing as some people do these things anyway - bear in mind that said substances aren't recommended for studio work, but voice recording devices are pretty cool for getting an idea noted down as fast as you can speak or sing it and before you forget what it was...
Edit: I would in no way recommend or condone this course of action but those people who do it might as well do it right.