class ActiveRecord::Reflection::ThroughReflection

def nested?

A through association is nested if there would be more than one join table
def nested?
  source_reflection.through_reflection? || through_reflection.through_reflection?
end