Keep in mind that we're each an experiment of one; all my suggestions have been shouted down by someone for whom these don't work. Still, these do work for this one:
1. Stretch, either when you feel a cramp coming on, as soon as you get off the bike, or later in the day.
2. Salt. On potatoes, in drink mixes or as an add-in, and if those don't work, an old-fashioned salt pill in between two full glasses of water.
FWIW, I used a half-and-half mix of lite salt (with potassium chloride) in my drinks for a while, and never really noticed it was better than plain table salt.
3. Massage, professional, friendly, or self-performed.
4. Salt-rimmed margaritas. You get some salt, you get relaxed, after a couple you hardly even care --- especially if you're dehydrated.