Yeah, this is a good old trick. You don't have to let the ballista crew die (I always use a ballista since it's easier to move them around the gates); just have them abandon the implement in the gateway and no ram can get past it.

A slightly less exploitative trick is simply to attack the ram crew and then retreat. The AI will abandon the ram even if you don't kill a single member of the crew and 99% of the time they won't pick it back up or send a new crew forward. You can do this over and over for multiple rams.

FYI the AI is pathetic at sieges. It's literally broken IMHO. Just wait until you see them try to capture huge walls with a siege tower.