Some investors in railroads have lately had a great ride.

Whatever happens with the potential tie-up of Canadian Pacific Railway Ltd. and CSX Corp., reported Sunday by The Wall Street Journal, investor William Ackman has made a lot of money in Canadian Pacific, which he started buying about three years ago.