Returns true if the collection is empty.
If the collection has been loaded or the :counter_sql option is provided, 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 294 def empty? if loaded? || options[:counter_sql] size.zero? else @target.blank? && !scope.exists? end end