diff options
author | Ernie Miller <ernie@metautonomo.us> | 2008-08-28 14:01:42 -0400 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-28 11:58:25 -0700 |
commit | 44af2efa2c7391681968c827ca47201a0a02e974 (patch) | |
tree | a25ede2a88799c281468fcdaa4321d6048cee240 /activerecord/lib/active_record/associations/has_many_association.rb | |
parent | ce4d13861dc54a1ac7fbe411327b9a2427f95366 (diff) | |
download | rails-44af2efa2c7391681968c827ca47201a0a02e974.tar.gz rails-44af2efa2c7391681968c827ca47201a0a02e974.tar.bz2 rails-44af2efa2c7391681968c827ca47201a0a02e974.zip |
Refactored AssociationCollection#count for uniformity and Ruby 1.8.7 support.
[#831 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 1535995410..1838021d40 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -1,32 +1,6 @@ module ActiveRecord module Associations class HasManyAssociation < AssociationCollection #:nodoc: - # Count the number of associated records. All arguments are optional. - def count(*args) - if @reflection.options[:counter_sql] - @reflection.klass.count_by_sql(@counter_sql) - elsif @reflection.options[:finder_sql] - @reflection.klass.count_by_sql(@finder_sql) - else - column_name, options = @reflection.klass.send(:construct_count_options_from_args, *args) - options[:conditions] = options[:conditions].blank? ? - @finder_sql : - @finder_sql + " AND (#{sanitize_sql(options[:conditions])})" - options[:include] ||= @reflection.options[:include] - - value = @reflection.klass.count(column_name, options) - - limit = @reflection.options[:limit] - offset = @reflection.options[:offset] - - if limit || offset - [ [value - offset.to_i, 0].max, limit.to_i ].min - else - value - end - end - end - protected def owner_quoted_id if @reflection.options[:primary_key] |