A rail is a bar and railings are sets of bars used to enclose space. Timber railings are ancient - and may have been the means by which the first gardens were enclosed. Cast iron and wrought iron are much more expensive materials. When first used in gardens, they were, relatively, far more expensive than they are today. Only the rich could afford metal railings: they were an ostentatious way of showing off to one's neighbours.
Wrought iron railings are older than cast iron railings. Wrought iron, which means 'worked iron' is made by heating the material to red heat in a furnace and then hammering it on an anvil. This process strengthens the material and drives out impurities. Traditional blacksmith-wrought iron is more rust-resistent than the modern equivalent, which is really mild steel. Mild still is produced in a mill and merely shaped by the blacksmith. It needs careful rust treatment. The process known as galvanisation is the most effective. It is an electrolytic process which coats the metal in zinc. Modern paints are also effective.
Cast iron railings are made by heating the metal until it is a liquid. The molten iron is then poured into moulds and allowed to set. Cast iron tends to rust on the surface, unless treated, but the rust tends not to go deep unless the iron is in contact with another metal.