For some reason, when plants flower when we want them to, we call it blooming. When plants flower when we don't want them to, we call that bolting!
Annual cool season vegetables including lettuce and spinach will bolt as days grow longer in summer. Bolting usually brings on bitter flavors in the foliage as will the usually hot temperatures that come along with longer days. Hot temperatures also cause the flowers to come on more quickly as will dry soil. Some biennial vegetables bolting is induced by a cold snap during a plants normal vegetative stage. Prone to bolting include rhubarb, Chinese cabbage, and mustard greens.
Some biennial vegetables, (those that normally produce only vegetative structures their first year, flower and seed their second year), may bolt during the first growing season in response to a cold spell. Most biennial vegetables, including onions, carrots, heading cabbage, have to reach a certain stage of growth before they are able to start the flowering process. But turnips are sensitive to cold as soon as they germinate.
Bolting cannot be reversed once the flowering process has begun, so replace affected plants with heat-tolerant summer crops or wait until later summer to replant for a fall harvest.