For me, it depends upon the ship...I will usually paint the hull first, paint the rails a corresponding color, then attach.
I will usually use a super fine glue tip (made from the tube of a Windex bottle, and stretched like sprue) to place a bead of glue along hte interior deck/rail edge. Once that's dried, I will go back with an artist's liner brush (verrry long bristles, used to paint pinstripes, etc) and clean up the area. Once that's done, a coat of clear flat.
There are times when I will apply PE rails during the construction process, a perfect example is my 1/700 Chokai bridge area. This is usually reserved for places that would be very tough to reach once the model is assembled.
If you have a specific example (ie., bridge structure on a Fletcher) I'll be glad to help out.
Regards,
Jeff Herne