If the entire rail needs to be replaced, dismantle that section of fence and rebuild it as explained below.
Step 1: Cut 2x4 rails to fit flat along the tops of the posts. The rails can extend from post to post, or a rail can span two sections. Measure and cut each rail individually to allow for slight variations in the fence post spacing. Butt the ends of the rails tightly together. Then, beginning at one end of the fence line, nail rails in place with two 10d galvanized common nails at the ends of each rail.
Step 2: Measure and cut the 2x4 bottom rail to fit snugly between each pair of posts. Position the rails flat between the posts, anywhere from slightly above grade level to 12 inches up. Nail the bottom rails into place with a 10d galvanized nail driven at an angle through the fence post and into the end of the rail on each side. Use a level to keep rails even.
Step 3: Measure and cut the fence boards. They should be of uniform length, as long as the distance from the bottom of the bottom rail to the top of the top rail, as measured at one of the posts. Starting at one end, nail boards to one side of the rails, leaving space equal to a single board width between each. Secure each board to the rails with two 8d galvanized nails at the top and two at the bottom. Nail tops first, flush with the top, then nail the bottoms, pulling or pushing the bottom rail into alignment as you go. If your fence will have boards on both sides, nail up all the boards on one side first, then nail alternate boards to other side of the rails, positioning boards to cover spaces left by boards on opposite side.