Browse files

revises RDoc of AR::Base#==

  • Loading branch information...
1 parent 4718d09 commit a820d0afdd4a09e0902d7b7c4d9724f50089d254 @fxn fxn committed Nov 16, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 activerecord/lib/active_record/base.rb
10 activerecord/lib/active_record/base.rb
@@ -1582,7 +1582,15 @@ def column_for_attribute(name)
- # Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id.
+ # Returns true if +comparison_object+ is the same exact object, or +comparison_object+
+ # is of the same type and +self+ has an ID and it is equal to
+ #
+ # Note that new records are different from any other record by definition, unless the
+ # other record is the receiver itself. Besides, if you fetch existing records with
+ # +select+ and leave the ID out, you're on your own, this predicate will return false.
+ #
+ # Note also that destroying a record preserves its ID in the model instance, so deleted
+ # models are still comparable.
def ==(comparison_object)
comparison_object.equal?(self) ||
comparison_object.instance_of?(self.class) &&

0 comments on commit a820d0a

Please sign in to comment.