instance method
include?
Ruby on Rails 7.0.10
Since v6.1.7.10Signature
include?(record)
Returns true if the relation contains the given record or false otherwise.
No query is performed if the relation is loaded; the given record is compared to the records in memory. If the relation is unloaded, an efficient existence query is performed, as in #exists?.
Parameters
-
recordreq
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 352
def include?(record)
if loaded? || offset_value || limit_value || having_clause.any?
records.include?(record)
else
record.is_a?(klass) && exists?(record.id)
end
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 352
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods