To show how the rail gun works we must prove two things:

1)  A current carrying wire produces a magnetic field.

2)  A current carrying wire in a magnetic field is acted upon by a force.

If you have a compass, battery, and a piece of wire, you should get it for the following discussion.

A diagram of the magnetic field produced by a current carrying wire is shown below:

Only a few of the circles have been drawn.  The direction of the magnetic field is determined by the right hand rule:  Grasp the wire in the palm of your right hand with your thumb pointing in the direction that conventional current is flowing through the wire.  Remember that conventional current is directed from positive to negative.

Conventional current is different than electron current which flows from negative to positive.  Since it is often remarked that it is actually electrons that move through the wire, which is true, and that the positive charges (atomic nuclei) are stationary, people say that conventional current should be redefined as being directed the same way as the electrons.  However, everything is relative, and we could argue that the lack of electrons travels the other way.  Picture a row of seats in a theatre where each seat is occupied except for the one on the end.  Each person is an electron and the empty seat is the lack of an electron, which we will call a hole.  Suppose the one person next to the empty seat moves over to fill it.  Now the seat he used to occupy is empty.  The resulting picture is that an electron has moved one way and the hole has moved the other way.  Suppose the next person moves to fill the seat the first electron just vacated.  Now the hole has moved another seat in the opposite direction of electron flow.  So when we speak of conventional current we refer to the direction of hole movement.

Back to our wire.  With the wire grasped in the palm of your right hand and your thumb pointing from positive to negative your fingers point in the direction of the magnetic field created by the current flowing through the wire.  You can rotate your hand around the wire and notice that the magnetic field is directed tangent to any circle concentric with the wire, which is just a fancy way of describing the picture shown above.

How can we prove to ourselves that this magnetic field exists?  We need a magnetic field detector, also known as a compass!  Magnetic field lines are always directed from north magnetic poles to south magnetic poles.  The earth's magnetic field is shown in the picture to the right.  Notice that the North and South geographic poles that we are familiar with are on opposite ends of the planet from the magnetic poles.  To explain this let's remember that a compass is a bar magnet mounted on a pivot so that it can turn to align with the net magnetic field around it, and remember that opposite magnetic poles attract.  Therefore, the north end of the compass bar magnet will point to the Earth's north geographic pole, since that is the south magnetic pole.  It makes sense to call that direction north since the north end of the compass points there.

What we have seen is that a compass aligns itself with the magnetic field so that the north end points in the same direction as the magnetic field.  Now we can use it to test the direction of the magnetic field produced by a current carrying wire.  Place your compass on the table in front of you and rest the wire on top of it parallel with the compass needle.  Now, supposing the geographic south end of the wire is connected to the positive terminal of your battery and the north end to the negative terminal, we expect a magnetic field directed west underneath the wire where the compass is.  Since the compass needle aligns with the north end pointing the direction of the magnetic field we expect the needle to turn anti-clockwise so that its North end now points west, right?  Try it!  You probably notice that it doesn't quite point straight west, and this is because the Earth's magnetic field is still pointing north.  The needle aligns with the sum of the magnetic fields from the Earth and wire.

What would happen if you keep everything the same, except put the wire under the compass?  Use the right hand rule to explain the effect. (The North end turns to point East!)