Haki, specifically Armament Haki, was not yet introduced as a concept yet at the time, so the only way to hurt a Logia user is to exploit their element. Luffy was already able to do this to Crocodile by dousing his body with water, forcing the sand to stick together.
Enel's body is made of lightning/electricity. He can let most normal objects pass harmlessly through his body, since most substances can conduct electricity. However, rubber is an insulator, meaning that it does NOT conduct electricity. Therefore, when Enel's electrical body comes into contact with Luffy's rubber body, he cannot conduct his body through it. So instead, his body interacts with rubber as if his body was normal flesh. This allows Luffy to inflict damage on him.
Note that rubber is not the only insulator. Glass is also an insulator, so if you were to attack Enel with a weapon made of glass, it would have the same effect. Hope this helps.