From 1dd90f8f12d1904ee3db37f9390df3246bb2712b Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Wed, 11 May 2011 08:55:36 +0100 Subject: Don't use select() values from the join model of a through association. Fixes #508. --- activerecord/lib/active_record/associations/through_association.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (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 e436fef46d..53c5c3cedf 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -14,9 +14,10 @@ module ActiveRecord def target_scope scope = super chain[1..-1].each do |reflection| - # Discard the create with value, as we don't want that the affect the objects we - # create on the association - scope = scope.merge(reflection.klass.scoped.create_with(nil)) + scope = scope.merge( + reflection.klass.scoped.with_default_scope. + except(:select, :create_with) + ) end scope end -- cgit v1.2.3