instance method
include?
Ruby on Rails edge
Since v4.0.13Signature
include?(record)
Returns true if the given record is present in the collection.
“‘ class Person < ActiveRecord::Base
has_many :pets
end
person.pets # => [#<Pet id: 20, name: “Snoop”>]
person.pets.include?(Pet.find(20)) # => true person.pets.include?(Pet.find(21)) # => false “‘
Parameters
-
recordreq
Source
# File activerecord/lib/active_record/associations/collection_proxy.rb, line 1000
def include?(record)
!!@association.include?(record)
end
Defined in activerecord/lib/active_record/associations/collection_proxy.rb line 1000
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Associations::CollectionProxy