aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-09 08:54:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-09 08:54:02 +0000
commit0faca07056e2dd6284d79522614cb991a680d5d0 (patch)
treec4b49d733b35142b98d40cf9e89866631474e870 /activerecord/lib/active_record/base.rb
parent74896c0252bf76c159a40895a5dfe2e75ab112bf (diff)
downloadrails-0faca07056e2dd6284d79522614cb991a680d5d0.tar.gz
rails-0faca07056e2dd6284d79522614cb991a680d5d0.tar.bz2
rails-0faca07056e2dd6284d79522614cb991a680d5d0.zip
Fixed comparison of Active Record objects so two new objects are not equal #2099 [deberg]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2172 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index f11fca69f4..e0bce194b2 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1169,7 +1169,10 @@ module ActiveRecord #:nodoc:
# Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id.
def ==(comparison_object)
- comparison_object.equal?(self) or (comparison_object.instance_of?(self.class) and comparison_object.id == id)
+ comparison_object.equal?(self) ||
+ (comparison_object.instance_of?(self.class) &&
+ comparison_object.id == id &&
+ !comparison_object.new_record?)
end
# Delegates to ==