Ecuador is renowned for its scenic railroad routes, some of which plunge down the steep face of the Andes range. The views are even more spectacular (and dangerous) if you ride on the roof of the train, a hallmark of Ecuadorean train travel. Be aware that the troubled infrastructure of the country's rail system makes for frequent schedule changes and last-minute service cancellations, so check locally for the latest word.
One of the most spectacular routes runs from Riobamba down toward the Pacific coast. One day, this route may once again connect up with Duran, across the bay from Guayaquil, but service currently terminates at Alausi (the tracks are out of commission farther west). The highlight of the trip is "the Devil's Nose," where the train traverses a series of zigzagging switchbacks down a nearly vertical incline. The train usually runs Wednesday, Friday and Sunday, leaving Riobamba very early in the morning, around 7 am. (You may have to catch a bus on the far end of the route.)
A more dependable (though more expensive) option for riding the rails through the country is to take the Chiva Express, offered by Metropolitan Touring (http://www.metropolitan-touring.com). The wagons are a cross between a typical Ecuadorean open-sided bus and a train carriage and run from Quito to Cotopaxi National Park. Buses then take you on to Riobamba, to catch their Devil's Nose train the following morning. Then you can choose to go by bus to Cuenca or continue on (also by bus) to Huigra and take the train to Bucay, enjoying the transition of the landscape from the Andes to the coastal lowlands before returning by bus to Quito.
Ecuador's other famous train ride ran from the Andean city of Ibarra to the coastal town of San Lorenzo. Mudslides have put this route out of commission indefinitely, but there's hope it will be resuscitated.