Small fibreglass boats are usually fitted with a rub rail to cover the joint between the hull and the deck, and to absorb the occasional bump against the dock. The Seatalk dictionary describes the rub rail as a "sacrificial fender", suggesting that it is easier to repair than a damaged hull.
Lift the damaged rub rail away and examine the condition of the joint between the deck and hull. Scrape off old adhesive and dirt to be sure the joint is sound. Based on what you find, decide whether to repair or replace the rub rail.
Drill out rivets or screws that have pulled through and remove them. Clean the screw holes in the hull and fill them with epoxy. Repair any damage you find. Any damage to that joint must be addressed first or the boat will leak.
Pull the insert out of the rub rail track, using heat to soften the material slightly. A hair dryer works fine. Remove and replace the metal strip at the bottom of the track. Smooth any scratches on the rail with fine sandpaper. If you find serious damage, replace a portion of the rail or the entire part.
Pull the rail back in position, stretching the free end so that it fits closely. Drill pilot holes through the metal strip and into the hull, spacing the fasteners every three or four inches. Dip the fasteners in a sealant to make the holes watertight. Use stainless steel screws to secure the track.
Stretch the insert along the track using heat if necessary, and force it firmly into place.
Trim and clean the repair, then replace any cap or trim pieces over the ends.
Boat surveyor D. H. Pascoe advises using through bolts instead of screws for fastenings.
Epoxy contains hazardous chemicals. Use eye protection.