When thanking someone, what is the rule for using ありがとうございます vs. ありがとうございました? My sensei taught us to use ありがとうございました when the action you're thanking someone for occurred in the past, but I've heard ありがとうございます used plenty of times right after the action occurred. Does it have to do with how far in the past the action happened?
In my opinion,
You can use ありがとうございます most of the time, but ありがとうございました cannot used when the request is not finished yet. For example.,
A quick search on Google of "ありがとうございます" "ありがとうございました" shows many discussions about the usage of these two expressions, mostly in Japanese (presumably by many Japanese people), and there does not seem to be a definitive answer.
What your teacher told you about it is correct as a general rule, but as YOU said, ありがとうございます is appropriate also when you thank someone for an action in the past. Some people claim that they feel annoyed by the phrase ありがとうございました because it implies that the thanks themselves ended in the past, but not everyone agrees on this.
There is one case where ありがとうございました is much more usual than ありがとうございます: when you close a talk by saying “Thank you for your attention,” the common (and I think formal) phrase is ご清聴ありがとうございました, not ご清聴ありがとうございます, although the action for which the speaker thanks has been (hopefully) continuing as he/she says this sentence. I cannot explain why, except that this is a fixed phrase and fixed phrases often break a general pattern.