module ActiveRecord::Associations::ThroughAssociation

def stale_state

to try to properly support stale-checking for nested associations.
Note: this does not capture all cases, for example it would be impractical
def stale_state
  if through_reflection.belongs_to?
    Array(through_reflection.foreign_key).filter_map do |foreign_key_column|
      owner[foreign_key_column]
    end.presence
  end
end