diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 11:53:49 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-06 11:53:49 +0000 |
commit | 5e44eda7872c6ee33e0d09a4b9fd78896e14b95a (patch) | |
tree | b64009226562aa04ce107692e726f545b3f9895f /activerecord/lib | |
parent | dfac1cea3d851000116a23ab14c2b1ae981f7a12 (diff) | |
download | rails-5e44eda7872c6ee33e0d09a4b9fd78896e14b95a.tar.gz rails-5e44eda7872c6ee33e0d09a4b9fd78896e14b95a.tar.bz2 rails-5e44eda7872c6ee33e0d09a4b9fd78896e14b95a.zip |
Fixed that HasManyAssociation#count was using :finder_sql rather than :counter_sql if it was available #445 [Scott Barron]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@834 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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 |