Ray isn`t rotating together with the object

I have a cube which looks (LookAt) a sphere.
I can move the sphere with the mouse — and so the cube rotates as well, looking at the sphere, everythings fine. Im casting a ray from the cube:

Physics.Raycast (transform.position, transform.forward, 10);
Debug.DrawRay(transform.position, transform.forward * 10, Color.red);

And when I look in the Scene View there is a red ray indeed — but it isnt rotating together with the cube, it isnt “looking” at the spehere. It`s just pointing the same way it did when it was cast.

so we have a cube looking at a sphere. the sphere follows the mouse while staying on a horizontal plane, and stays within a fixed distance from the cube.

sphere script:

using UnityEngine;
using System.Collections;

public class scriptSphere : MonoBehaviour {
	
	public Transform anchorTransform;
	public float anchorMaxDistance;

	void Update () {
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		Plane hPlane = new Plane(Vector3.up, Vector3.zero); //horizontal plane going through (0,0,0)
		float rayDistance; //distance from the camera to the plane
		Vector3 p = Vector3.zero; //point under the cursor
		
		if (hPlane.Raycast(ray, out rayDistance)) { //make sure it actually intersects
			p = ray.GetPoint(rayDistance);
		}
		
		Vector3 v = Vector3.ClampMagnitude(p - anchorTransform.position, anchorMaxDistance);
		
		transform.position = anchorTransform.position + v;
	}
}

cube script:

using UnityEngine;
using System.Collections;

public class scriptCube : MonoBehaviour {
	
	public Transform target;
	
	void Update () {
		transform.LookAt(target);
	}
}