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!)

Great work!  If you've carried out the above exercise you have convinced yourself that a current carrying wire produces a magnetic field, and we've proven 50% of what we need to know to understand the rail gun.  The next step is to show that when we place a wire in a magnetic field and pass a current through it, a force will be exerted on the wire.  The direction of that force is given by another right hand rule.  Label the middle finger of your right hand with the letter F which stands for force.  Then label your index finger B, for magnetic field, and your thumb I for current.  Now you have to arrange those three fingers so that they're all 90 degrees to each other, like this: make an "L" with your thumb and index finger, then point your middle finger in the direction your palm is facing.  To make sure you have it right, please refer to the picture to the right, where we have a wire lying along the x axis.  The x and y axes are in the plane of your computer screen (just like a piece of paper put on the screen would be) and the z axis is coming out of the screen towards you.  The blue rectangle just illustrates that the green and blue arrows are also in the plane of your computer screen.  With your right hand (don't use your left!) arranged as before, point your thumb in the direction of the current (the green arrow), and then point your index finger in the direction of the magnetic field (blue arrow).  Your middle finger gives us the answer we've been looking for:  the force on the wire is directed out of the screen towards us (along the red arrow).  Great, now let's talk about the rail gun.

The drawings on the picture to the right illustrate how the right hand rule can be used to understand the rail gun.  The blue circles show the direction of the magnetic field produced by the rails when current passes through them.  Current is directed from the positive red wire to the negative black wire, as shown by the green arrows.  At the graphite projectile we notice the current travelling straight to the right, while the magnetic field between the rails is pointing straight up.  That is the exact same situation shown in the diagram above, and we know the result will be a force as shown by the red arrow.  The thumb goes in the direction of the green current, the index finger points up along the blue magnetic field, and your middle finger shows the force is directed down the rails.

When the rails are positioned between the poles of the large horseshoe magnet the fields from the rails and magnet add together between the rails  This causes the force on the projectile to be much greater.

So that's the story of the model rail gun, and real life versions will be based on the same principles of induced magnetic fields and forces applied on current carrying projectiles in a magnetic field.  Hope you enjoyed!