It actually depends. If it refers to the/a ray of sun then it is "le rayon de soleil." But if there is a qualifier, as in the example "les deniers rayons du soleil." then it's "du" instead of "de". Hard for me to explain but there's a nuance: The sun ray, or a ray of sun,(de soleil) versus, "the last ray of the sun." (du soleil.)
It would be understood without any trouble. But even though people think of the sun as having rays, and "ray of sun" is regularly used as a caption under photographs, in lyrics, and in headlines, "you are my ray of sun" when said to a beloved feels like broken English. It is much better to use "ray of sunshine" in that case.
It generally sounds better if you use "ray of sunshine" or "sunlight". Never "ray of sunbeam"! A sunbeam is the same as a ray of sunlight.