The story
Probably from rebracketing of gaydar, itself a blend of gay + radar. Alternatively radar might have been rebracketed directly as ray + -dar, but this appears less likely because rays are, if anything, that by means of which a radar detects things.
Etymology from Wiktionary, CC BY-SA 4.0.