Returns true if the collection is empty.
If the collection has been loaded it is equivalent to collection.size.zero?. If the collection has not been loaded, it is equivalent to collection.exists?. If the collection has not already been loaded and you are going to fetch the records anyway it is better to check collection.length.zero?.
# File activerecord/lib/active_record/associations/collection_association.rb, line 317 def empty? if loaded? size.zero? else @target.blank? && !scope.exists? end end