This is a "feature" of rings. If you are within about 500LY of civilization, any time you enter a ring a pirate or two will spawn a couple of minutes later.Besides this, I had a pirate problem. When I entered the ring, I was completely alone. Noone on the radar, noone moving around, even after waiting some time.
Then I started mining, collected some gold in the process - that rock I had chosen had quite a bit of it.
Then, after I had been mining for some minutes, someone dropped in on me, scanned me and started shooting. So I ran, leaving uncollected goods and limpets behind...
So, what you need to do is enter the ring, wait a bit until the pirates show up, let them scan you (if you only have limpets they will not attack), then wait a while until they fly away and you see their wakes left behind.
After that you can mine in peace and they will not return (unless you log off and on, or exit and re-enter the ring).
If you don't want to wait around for all that, or if you have something other than limpets in your hold, you can also just boost, boost, boost away from the spot where you entered the ring. Get far enough away and they will probably not find you. It's a bit riskier, but it does work as long as you fly far enough