Rotate a ship with a mouse ray

I need to cast an invisible ray out from my third person camera, then rotate the camera/ship to follow that ray’s direction. This should create the effect of constantly rotating the ship while away from the camera/screen center. I’ve had no luck with any of the Lerp or RotateTowards methods either. If it helps; my camera is located behind the ship and locked to it. When the ship moves so will the camera. This is a 3D spaceflight game.

I’m not asking for source code, just a general solution or at the very least some explanation of how the methods I mentioned (Lerp, RotateTowards) work, because I don’t understand them (or I’m just not using them properly).

From my answer to this question. You should use Quaternion.FromToRotation. And after that, use Quaternion.Lerp. Something like this (This code should be in FixedUpdate for smooth results):

 Vector3 direction = Vector3.forward; //Put your ray direction here
Quaternion toRotation = Quaternion.FromToRotation(transform.forward, direction);
transform.rotation = Quaternion.Lerp(transform.rotation, toRotation, speed * Time.time);

You can set the speed variable to how slow or fast you want the rotation to be. Put this code on your ship. This is the third time today that I am answering a question with this same answer ;).