diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index f1bec5787ae835fe114f61cce2a27fc5ca3661bd..bdfafa506653c8ad3157f9060213781eb1bda904 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -119,7 +119,7 @@ def table_name_for(reflection) # the owner klass.table_name else - reflection.table_name + super end end diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 8a9488656bd9d18e6d48fc027c0337803d0ff656..f470946da58a695d95b2ce1439a2a258c42b099d 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -527,7 +527,9 @@ def through_reflection # def chain @chain ||= begin - chain = source_reflection.chain + through_reflection.chain + a = source_reflection.chain + b = through_reflection.chain + chain = a + b chain[0] = self # Use self so we don't lose the information from :source_type chain end