Many horrible, inhumane products were patented in the early late 19th and early 20th centuries to help prevent self-stimulation or "self-abuse" as it was called. Products range from a mini spiked bear-trap for penises to the invention of Graham crackers.
The Bowen Device
The French Electrical Device
This French anti-stimulation device called simply "Electric anti-masturbation machine" (from 1915 France), would have the person with a penis wear a ring connected to an electrical system.
The machine was electric, and the rising of the member set off an electric mechanism that triggered an alarm bell and let the person - and everyone else within a one-mile-radius - know the person was trying to self-stimulate.
The Cold Water Shower
In 1893, a man named Frank Orth devised an anti-stimulation/nocturnal emission device that relied on an early version of the George Costanza "shrinkage" hypothesis.
While wearing a pair of waterproof pants, a person’s shaft would be slipped into a front section, nestled between two levers. As the person slept, should the member expand, it would set off the levers and release cold water to fill up the chamber and diminish the erection.
This penis cage was not an anti-erection device, like most of these in general (that would keep people from being able to get an erection), but it would actually allow for erections - which is the beginning of the end. When fully erect, the cage served its purpose: to let people have erections, but not let anything happen as arousal began.