To outline a stroke so you can create a gradient, you must select it, then go to Object > Expand...
Make sure "Stroke" is selected, and click OK. If the original path had a fill, other than none, it will still be there, but as a separate shape grouped to the outlined stroke. You may need to ungroup it if you want to treat it differently.