Tim,
Most people spray the bed first. I have heard of a few mounting the hitch rails first but very few. Spray it, the hitch it - you'll be happy. Also consider getting the over-the-rail process. I am glad I did. Sure saves on scratches when loading and unloading anything over the side. Also helps make the top of the rails a bit non-slip for walking on.
Best of luck,
Jim