That's just an Old Maid's tale.
Old maid's tale or not, beans often give me gas as is the case with most people I know. There are several recipes for beans which are supposed to help with this.
Beans (legumes) cause gas because they contain a particular sugar, oligosaccharide, that the human body can not break down. Oligosaccharides are large molecules and are not broken down and absorbed by the lining of the small intestine as other sugars are. This is because the human body does not produce the enzyme that breaks down oligosaccharides.
Foul smelling gas is caused by eating foods which contain sulfur. Therefore, eating foods that are high in sulfur, such as garlic, onions, leeks, broccoli, cauliflower, cabbage and Brussels sprouts, can cause foul-smelling gas.
Intestinal gas is primarily composed of hydrogen, nitrogen, and carbon dioxide -- which are all gasses that are odorless. In about one-third of people, intestinal gas also contains another ingredient: methane. It's unclear why some people's bodies produce methane and others do not. People who produce methane typically will have stools that float in water.