I've had the same problem. Standard Ensign rub rail installation has a plastic C clip (rigid track insert) pressed onto the flange which secures the rub rail nicely. A cross section detail is attached. I received my boat without the clip. Turns out the clip is hard to install over the rivets that secure the hull/deck flange faces; and some boat restoration shops feel the clip is unnecessary. Both our experiences suggest otherwise.
I'm sure there are several equally good ways to fix this problem. I resolved mine by obtaining a section of rigid track insert from Ensign Spars, cutting it into 6-8 inch lengths, then securing these lengths to the hull with non-permeant 3M adhesive every 4- feet or so. See attached image. In short sections the clip secures well over the hull/deck flange rivets, and there is no compromise to hull integrity. The entire job, from first cutting the track to finally repressing the rub rail back into place took less than an hour; and required nothing more than a caulk gun and rubber mallet. It has held up well through numerous high-heel (water over the gunnel) situations that would have previously pulled the rail away.