The WD-40 is OK but I prefer to use a carburetor-choke cleaner and wipe it down with one of the green Scotchbrite pads then paper towel. Depending on how dirty the rail is, it may take several applications. The imprortant idea here is to clean off the deposits and reduce the abrasion of the rail guide. Lubrication is best done sparingly, such as a silicone lubrication spray.
To reduce the amount of time spent on cleaning try getting a nylon bristle brush from a firearms dealer. They are usually sold as pistol chamber brushes and are approximately 3/4" to 1" in diameter. Put a 45 degree bend in the twisted wire handle and use it with your favorite lube/cleaner to clean out the slot in your rails. It will completely clean a badly crudded up rail in only one or two passes. A friend, Andy Miller, and I confirmed this by cleaning a very dirty 1.5" X 12' rail that had been used at LDRS this year in only 5 minutes.
Also in regards to cleaners I use WD40 when the deposits are fresh or light. For really heavy deposits or deposits that have hardened over time try Hoppe's "No. 9 Plus Black Powder Cleaner And Patch Lube". It dissolves exhaust deposits like nothing else does.