Krupp K5, a WWII German rail gun; ca. 1944.
The Krupp K5 was a rail gun, in that it was transported by rail and was mounted on a carriage that rode on several sets of parallel, curved track in order to train the gun. It did not use an electromagnetically-powered carriage riding between two rails to launch its projectile.
Several other proposals were made to modify or create new models of the K5 which never saw production. In particular, there were plans for a model which could leave the railway by use of specially modified Tiger II tank chassis which would support the mounting box in much the same manner as the railway weapon’s two bogies. This project was ended by the defeat of Germany. (Source)
Take a very close look at this picture of the K5. at the end of the barrel you can see groves on the inside of the barrel. These grooves are 8cm deep and go all the way down the length of the barrel in a helical pattern like this. This is called rifling.
When the gun fires, the ‘bullet’ is put under tremendous forces, and as a result is compressed lengthwise. The compression also pushes parts of the bullet into the groves, and as the bullet travels down the barrel, it locks onto the groves, causing it to spin. This spinning is important as it keeps the bullet stable and pointing forward for the entire duration of it’s flight, taking advantage of gyroscopic stability.