No documentation

# File activerecord/lib/active_record/associations/join_dependency/join_association.rb, line 62def join_to(relation)tables=@tables.dupforeign_table=parent_tableforeign_klass=parent.active_record# The chain starts with the target table, but we want to end with it here (makes# more sense in this context), so we reversechain.reverse.each_with_indexdo|reflection,i|table=tables.shiftcasereflection.source_macrowhen:belongs_tokey=reflection.association_primary_keyforeign_key=reflection.foreign_keywhen:has_and_belongs_to_many# Join the join table first...relation.from(join(table,table[reflection.foreign_key].eq(foreign_table[reflection.active_record_primary_key])))foreign_table,table=table,tables.shiftkey=reflection.association_primary_keyforeign_key=reflection.association_foreign_keyelsekey=reflection.foreign_keyforeign_key=reflection.active_record_primary_keyendconstraint=build_constraint(reflection,table,key,foreign_table,foreign_key)conditions=self.conditions[i].dupconditions<<{reflection.type=>foreign_klass.base_class.name}ifreflection.typeunlessconditions.empty?constraint=constraint.and(sanitize(conditions,table))endrelation.from(join(table,constraint))# The current table in this iteration becomes the foreign table in the nextforeign_table,foreign_klass=table,reflection.klassendrelationend