Yonada course correction

A world-ship saved from collision

The Enterprise discovered that the inhabited asteroid Yonada was a generation ship on a collision course with a planet, and helped its people learn the truth and steer it clear.

In 2268 the Enterprise found an asteroid on course to strike the populated planet Daran V. It was Yonada, a hollow world-ship built by the Fabrini, whose people did not know they were on a ship. They were ruled by a computer known as the Oracle, which punished any disobedience.
McCoy, who had just learned he had a fatal disease, fell in love with the high priestess Natira and stayed to marry her. Kirk and Spock found the ship's control room and corrected Yonada's course. In the Fabrini records McCoy found a cure for his illness, and the people of Yonada continued their voyage.