Test for equality. Resource are equal if and only if other is the same object or is an instance of the same class, is not +new?+, and has the same id.
Examples
ryan = Person.create(:name => 'Ryan') jamie = Person.create(:name => 'Jamie') ryan == jamie # => false (Different name attribute and id) ryan_again = Person.new(:name => 'Ryan') ryan == ryan_again # => false (ryan_again is new?) ryans_clone = Person.create(:name => 'Ryan') ryan == ryans_clone # => false (Different id attributes) ryans_twin = Person.find(ryan.id) ryan == ryans_twin # => true
Source Code
# File active_resource/base.rb, line 595 def ==(other) other.equal?(self) || (other.instance_of?(self.class) && !other.new? && other.id == id) end
<code/>and<pre/>for code samples.