Method: ActiveRecord::Relation#any?

Defined in:
lib/active_record/relation.rb

#any?(*args) ⇒ Boolean

Returns true if there are any records.

When a pattern argument is given, this method checks whether elements in the Enumerable match the pattern via the case-equality operator (===).

posts.any?(Post) # => true or false

Returns:

  • (Boolean)


312
313
314
315
316
317
# File 'lib/active_record/relation.rb', line 312

def any?(*args)
  return false if @none

  return super if args.present? || block_given?
  !empty?
end