I know that who is used when asking about a subject (Who is at the door?) and whom is used when asking about an object (By whom was the door opened?). How do you determine which one to use when the object becomes the subject of another clause?
For example, take the sentence:
I gave the prize to ____ deserved it most.
Would it be whomever because it's the object of "gave," or would it be whoever because it's the subject of "deserved"? Is their a hard-and-fast rule to rely on in situations like this?