diff options
author | Ray Zane <raymondzane@gmail.com> | 2017-02-13 23:38:38 -0500 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-25 21:24:30 +0900 |
commit | 3d9e8d7c110f7053d73f61f2297bd46722294121 (patch) | |
tree | 90b6a60131dfd2f1f8707acd9ad4dc46b26c080e /activerecord/lib/active_record/associations/association_scope.rb | |
parent | 98d12f1ef31014287c897fc60df4e1af70781ca3 (diff) | |
download | rails-3d9e8d7c110f7053d73f61f2297bd46722294121.tar.gz rails-3d9e8d7c110f7053d73f61f2297bd46722294121.tar.bz2 rails-3d9e8d7c110f7053d73f61f2297bd46722294121.zip |
The AliasTracker#aliased_table_for needs the type caster for the joined association, not the join root
Diffstat (limited to 'activerecord/lib/active_record/associations/association_scope.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/association_scope.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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 |