Hello Shelly, you say you take your medication when needed, but for PPI medicines to reduce the acid production in your stomach they have to be taken as prescribed by your doctor, which is usually regularly. PPI pills don't work like antacids. So if perhaps you haven't been taking them right then the pain you are feeling could be due to the acid production having increased and be making the reflux worse. For the pain you describe is common with reflux acid. My ribs have been pained too on occasion.
I weaned off my PPI because it caused severe dryness in my throat and mouth. Since then I only treat my gastritis via diet, which is ongoing.
Just in case it might be helpful, here are my tips from my own experience of gastritis. Best wishes.
Several medium meals per day (I have seven, one every two hours or bit longer), rather than fewer bigger ones, so that you don't overfill and stretch/pressure the stomach. Be sat upright for and after meals, not bent or slouching, so you don't squash your tum and press its contents upwards.
We're all different and you might find some foods are ok or bad with you compared to other people, so it's a matter of experimentation, but fried foods, high-fat foods, high-salt foods, carbonated drinks, caffeine, alcohol and chocolate can all impact on stomach and reflux troubles. Spicy and hot foods can also aggravate the trouble for some people. Minty foods relax the lower eosophageal muscle too, which lets acid through easier, so they are bad. I even use a fruity toothpaste.
Stress and excercise that affect the stomach are also to be avoided. Be as calm and stress-free as you can.
Having your last meal a few hours before bed can prevent relfux at night, but you may find, as I did, that waiting to be too empty actually causes hunger discomfort and keeps you awake. Because of this I lie-down (on my right is best for me) about an hour and a half to two hours after last meal, and this is much better.
Another thing which has helped me, is to not burp after ten or so minutes after eating, as this can bring acid up and cause burn damage that then has to heal, even after a gaviscon. And don't take antacids routinely unless you need to during heartburn periods. I know you do, maybe as a preventative measure? but, if possible, you should have them only when needed, unless your doctor has advised it. The PPI will reduce your acid anyway, so you might find you don't even need to be taking gaviscon, but by taking it as a preventative measure you might not be able to tell.