Strip of magnesium ribbon
Two beakers half full of water
Wrap one nail with magesium ribbon. Place each nail in a beaker of water and add indicator. After a day or so, the nail without the magnesium ribbon will be rusty. The nail with the magnesium ribbon will not be rusty.
This method of preventing the corrosion of iron is called cathodic protection. The magnesium corrodes instead of the iron because it is more easily oxidized (it is above iron in the table of reduction potentials). The iron becomes the cathode at which oxygen is reduced to water leaving the iron unattacked. The more easily oxidized metal, in this case magnesium, is called a sacrificial anode.
The half reactions:
At the anode magnesium is oxidized:
Mg --->Mg2+ 2e-
At the cathode oxygen is reduced:
O2 + 2H2O + 4e- ---> 4OH-