diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 9aed6af48b..0f79e4ccef 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -33,7 +33,9 @@ module ActiveRecord # Count the number of associated records. All arguments are optional. def count(runtime_conditions = nil) - if @options[:finder_sql] + if @options[:counter_sql] + @association_class.count_by_sql(@counter_sql) + elsif @options[:finder_sql] @association_class.count_by_sql(@finder_sql) else sql = @finder_sql |