It's a common problem. Some runners resort to pre-race Imodium.
Best thing I've found is a really strong cup of coffee about an hour before I need to leave. Empty out ahead of time.
Second best thing is avoiding sugar on my ride. I try to fuel with real food as much as possible.
Even then, I've found myself in a woods or making a mad dash to a restroom if I'm lucky enough to have a convenience store nearby. My IBS really doesn't help that, though.