method
count_records
v2.1.0 -
Show latest stable
- Class:
ActiveRecord::Associations::HasManyAssociation
count_records()protected
No documentation available.
# 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