If you visit the town of Niantic or Rocky Neck State Park in Connecticut, you'll quickly find the Railroad slicing through some of their most beautiful views.
Why did the railroad build right off the beach instead of a bit inland?
Because people lived in higher density along the coast. Also, the land values were much lower in real terms than today. Clinton, Westbrook, etc. were fishing villages that had previously been a day’s walk to any large town.
Finally, trains brought a profound economic benefit far exceeding any loss to “attractiveness”. The alternative was horse and cart or, for most people, walking. Freight could be transported at a fraction of the cost-per-mile. One could argue the railway made expensive real estate possible over the long run by allowing professional classes to vacation, commute, etc. further along the coast in each direction.