size()
Instance Public methods
Returns the size of the collection. If the collection hasn't been
loaded, it executes a SELECT COUNT(*) query. Else it calls
collection.size.
If the collection has been already loaded size and
length are equivalent. If not and you are going to need the
records anyway length will take one less query. Otherwise
size is more efficient.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.size # => 3
# executes something like SELECT C