From 9bde73ff72812f6f3c59ad97be6ca6c628e109ea Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Tue, 6 Sep 2011 16:34:32 +0100 Subject: Nested through associations: preloads from the default scope of a through model should not be included in the association scope. (We're already excluding includes.) Fixes #2834. --- activerecord/lib/active_record/associations/through_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations/through_association.rb') diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 81172179e0..b010b5e9ef 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -16,7 +16,7 @@ module ActiveRecord chain[1..-1].each do |reflection| scope = scope.merge( reflection.klass.scoped.with_default_scope. - except(:select, :create_with, :includes) + except(:select, :create_with, :includes, :preload) ) end scope -- cgit v1.2.3 From 143769051bcf5b3a7600744be2d8db6e9c859288 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 7 Sep 2011 09:26:02 +0100 Subject: Don't include any of includes, preload, joins, eager_load in the through association scope. --- activerecord/lib/active_record/associations/through_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations/through_association.rb') diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index b010b5e9ef..b347a94978 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -16,7 +16,7 @@ module ActiveRecord chain[1..-1].each do |reflection| scope = scope.merge( reflection.klass.scoped.with_default_scope. - except(:select, :create_with, :includes, :preload) + except(:select, :create_with, :includes, :preload, :joins, :eager_load) ) end scope -- cgit v1.2.3 From b4b178f7e9a00a0235574a773cdbc06fe856acaf Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Thu, 3 Nov 2011 10:23:42 +0000 Subject: Fix #3247. Fixes creating records in a through association with a polymorphic source type. --- activerecord/lib/active_record/associations/through_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations/through_association.rb') diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index b347a94978..f95e5337c2 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -44,7 +44,7 @@ module ActiveRecord join_attributes = { source_reflection.foreign_key => records.map { |record| - record.send(source_reflection.association_primary_key) + record.send(source_reflection.association_primary_key(reflection.klass)) } } -- cgit v1.2.3