Use of the M-3 Carbine dates from Korea, but was standardized in August of 1945. Receiver mounted just like a regular rifle scope.
Hanging useless stuff on a rifle is a very late 20th Century thing. Poachers likely taped flashlights on vs a rail.
I'm sure there are earlier pistols, but the HK USP is the first integrated rail on a production handgun that I can think of off the top of my head. But, the idea must go back farther than the early 1990s, doesn't it?
One piece Weaver scope mounts are "rails", and I think the earliest thing that would fit the bill. Custom work mounted them on revolvers and some semis back in the 60s if not earlier.
poachers would use tape, and other things. You can do quite a bit with a couple of hose clamps, too.
First production pistol with a rail? no clue, sorry.
I'm still trying to figure out when the front of the frame became the "dust cover"...
The first "MasterKey" systems that were thought up by the guys in the girl scout hats at Bragg did just that.
In some of the photos from Somalia, you can see the guys with cut down 870s mounted to their CAR-15s with hose clamps.
In regards to the OP; in Ed McGivern's book Fast and Fancy Revolver Shooting he has a couple of S&W Registered Magnums with scope rails on them, the time period being late 30s to early 1950s.