How to change color along a curve?
The trick is to enable UV mapping on the curve and then use UV as the input texture coordinate. Then use can use the mapping node to rotate the default UV positioning to get the gradient to run along the length of the curve. Please note I had to adjust the X/Y scale factor to get the whole gradient to show on the curve.