I just forget about scales and theory and imagine the solo in my mind before I pick up my guitar. You get much better ideas through the mind than through the hands. Hear a solo/part/run/phrase in your mind as you listen to the backing riff then work it out note by note. I never bothered with theory and this method works fine for me. A solo should have direction (beginning, middle and end) like a musical story and shouldnt just be a collection of runs up and down.