One alternate approach would be to have the part of the rail which experiences wear be able to be quickly swapped out.
Alternately, the power that would be used by a railgun, could also be used by a laser, and high power lasers are coming along.
Lasers have come a long way and they will be deployed on large surface combatants and fleet auxiliaries very soon. But they will be primarily defensive weapons slaved to the Aegis air defense net. The idea is that the laser is best used against fast & 'softer' air & surface targets (drones, helicopters, small boats and surface-to-surface missiles). You don't want to expend your limited supply of Standard & Sparrow missiles against targets that are on the edges of their engagement envelope or too cheap to make for a decent exchange.