Created
May 4, 2010 22:06
-
-
Save cgriego/390091 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 14c3cd15dd0f50dc02fcfa1a01ad93c723bba36d Mon Sep 17 00:00:00 2001 | |
From: Chris Griego <[email protected]> | |
Date: Tue, 4 May 2010 17:05:42 -0500 | |
Subject: [PATCH] Fix halting callbacks | |
--- | |
lib/mongoid/persistence.rb | 3 ++- | |
lib/mongoid/persistence/insert.rb | 3 +-- | |
2 files changed, 3 insertions(+), 3 deletions(-) | |
diff --git a/lib/mongoid/persistence.rb b/lib/mongoid/persistence.rb | |
index d61f970..7c03d24 100644 | |
--- a/lib/mongoid/persistence.rb | |
+++ b/lib/mongoid/persistence.rb | |
@@ -120,7 +120,8 @@ module Mongoid #:nodoc: | |
def upsert(validate = true) | |
validate = parse_validate(validate) | |
if new_record? | |
- insert(validate).errors.any? ? false : true | |
+ document = insert(validate) | |
+ !document.errors.any? || document.persisted? | |
else | |
update(validate) | |
end | |
diff --git a/lib/mongoid/persistence/insert.rb b/lib/mongoid/persistence/insert.rb | |
index 007bb6b..909ffaf 100644 | |
--- a/lib/mongoid/persistence/insert.rb | |
+++ b/lib/mongoid/persistence/insert.rb | |
@@ -29,9 +29,8 @@ module Mongoid #:nodoc: | |
@document.new_record = false | |
@document.move_changes | |
end | |
- @document | |
end | |
- end | |
+ end; @document | |
end | |
protected | |
-- | |
1.6.5 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment