method
count_records
count_records()
protected
Hide source
# File activerecord/lib/active_record/associations/has_many_association.rb, line 22 def count_records count = if has_cached_counter? @owner.send(:read_attribute, cached_counter_attribute_name) elsif @reflection.options[:counter_sql] @reflection.klass.count_by_sql(@counter_sql) else @reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include]) end @target = [] and loaded if count == 0 if @reflection.options[:limit] count = [ @reflection.options[:limit], count ].min end return count end