From 82b244e3ffb55b94597b0562919522625ebfd2d3 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Thu, 16 Aug 2007 04:36:55 +0000 Subject: Make sure has_many associations honour :include when counting. Closes #9167 [danger] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations/has_many_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 838eb00863..c40982d738 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -99,7 +99,7 @@ module ActiveRecord elsif @reflection.options[:counter_sql] @reflection.klass.count_by_sql(@counter_sql) else - @reflection.klass.count(:conditions => @counter_sql) + @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]) end @target = [] and loaded if count == 0 -- cgit v1.2.3