In midlane you ALWAYS want to try to push for level 2 first, because it gives you an advantage that you can use to trade. But, when you do this, you'll end up pushing the wave underneath the enemy tower. Which is good. But, you'll die to ganks when you're harassing the enemy laner underneath the tower. Luckily there is a simple and easy way to fix that, and here is how.
The idea is you want to place a ward before the wave crashes underneath the enemy tower. Usually you'll find a window to do that between wave 1-2 or wave 2-3.
Now here is EXACTLY how you can use 1 ward to make you immune to ganks. First of all, you need to place the ward correctly.
The best position is just outside of the midlane bush in the river. Because this spots the most jungle paths.
So, how can 1 ward make you gank immune? The idea is, you ONLY play on the side of the lane that you have warded.
If the enemy jungler doesn't show up on the ward, well then that means he is on the opposite side of the map. Which means he will have a tough time ganking you, because you're hovering away from him.
And if you spot the enemy jungler on the ward? Well then you spotted the enemy jungler on a ward and you can run away and avoid the gank.
This concept works all the way into the later stages of the lane, to make sure you're safe from ganks.