instance method
==
Ruby on Rails 6.1.7.10
Since v4.0.13Signature
==(other)
Equivalent to Array#==. Returns true if the two arrays contain the same number of elements and if each element is equal to the corresponding element in the other array, otherwise returns false.
class Person < ActiveRecord::Base has_many :pets end person.pets # => [ # #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>, # #<Pet id: 2, name: "Spook", person_id: 1> # ] other = person.pets.to_ary person.pets == other # => true other = [Pet.new(id: 1), Pet.new(id: 2)] person.pets == other # => false
Parameters
-
otherreq
Source
# File activerecord/lib/active_record/associations/collection_proxy.rb, line 957
def ==(other)
load_target == other
end
Defined in activerecord/lib/active_record/associations/collection_proxy.rb line 957
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Associations::CollectionProxy