I'd try caulk or similar if gluing to the rails is wanted. Making sure it's paintable, just in case of a little weep.
For real strength, but removability and minor flexabilty, DAP red can contact cement ... two-three layers on each side, wait as instructed! (And ventilate)..squeeze, and maybe weight it or clamp for an hour(s) for an even better bond.