From 3d9e8d7c110f7053d73f61f2297bd46722294121 Mon Sep 17 00:00:00 2001 From: Ray Zane Date: Mon, 13 Feb 2017 23:38:38 -0500 Subject: The AliasTracker#aliased_table_for needs the type caster for the joined association, not the join root --- activerecord/lib/active_record/associations/association_scope.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/association_scope.rb') diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 1593b94f0c..4ce4252224 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -21,7 +21,7 @@ module ActiveRecord reflection = association.reflection scope = klass.unscoped owner = association.owner - alias_tracker = AliasTracker.create connection, association.klass.table_name, klass.type_caster + alias_tracker = AliasTracker.create connection, association.klass.table_name chain_head, chain_tail = get_chain(reflection, association, alias_tracker) scope.extending! reflection.extensions @@ -112,7 +112,11 @@ module ActiveRecord runtime_reflection = Reflection::RuntimeReflection.new(reflection, association) previous_reflection = runtime_reflection reflection.chain.drop(1).each do |refl| - alias_name = tracker.aliased_table_for(refl.table_name, refl.alias_candidate(name)) + alias_name = tracker.aliased_table_for( + refl.table_name, + refl.alias_candidate(name), + refl.klass.type_caster + ) proxy = ReflectionProxy.new(refl, alias_name) previous_reflection.next = proxy previous_reflection = proxy -- cgit v1.2.3