APIdock / Ruby on Rails
/
Browse About
method

any?

v6.0.0 - Show latest stable - Class: ActiveRecord::Relation
any?()
public

Returns true if there are any records.

# File activerecord/lib/active_record/relation.rb, line 277
    def any?
      return super if block_given?
      !empty?
    end

1Note

Should include information about optional block

charleschanlee ยท Mar 21, 20161 thank

If a block exists, will return true if any records in the relation is true for the given block. Otherwise, returns true is there are any records.

Related methods

  • Instance methods
  • ==
  • _exec_scope
  • alias_tracker
  • any?
  • arel_attribute
  • bind_attribute
  • blank?
  • build
  • cache_key
  • cache_version
  • create
  • create!
  • create_or_find_by
  • create_or_find_by!
  • delete_all
  • delete_by
  • destroy_all
  • destroy_by
  • eager_loading?
  • empty?
  • empty_scope?
  • encode_with
  • explain
  • find_or_create_by
  • find_or_create_by!
  • find_or_initialize_by
  • first_or_create
  • first_or_create!
  • first_or_initialize
  • has_limit_or_offset?
  • initialize_copy
  • inspect
  • joined_includes_values
  • load
  • many?
  • new
  • none?
  • one?
  • preload_associations
  • pretty_print
  • records
  • reload
  • reset
  • scope_for_create
  • scoping
  • size
  • to_a
  • to_ary
  • to_sql
  • touch_all
  • update
  • update_all
  • update_counters
  • values
  • where_values_hash
  • Class methods
  • new
  • Protected methods
  • protectedload_records
  • protectednull_relation?
  • Private methods
  • private_deprecated_scope_block
  • private_deprecated_spawn
  • private_increment_attribute
  • private_scoping
  • private_substitute_values
  • privatealready_in_scope?
  • privatebuild_preloader
  • privatecompute_cache_key
  • privatecompute_cache_version
  • privateexec_queries
  • privatereferences_eager_loaded_tables?
  • privateskip_query_cache_if_necessary
  • privatetables_in_string
APIdock API Documentation Browser

© 2026 APIdock