Commit 8f14cd7e by Tony Byrne

Do not save instances unless they have already been persisted. This allows AR's…

Do not save instances unless they have already been persisted. This allows AR's behaviour for unsaved instances to be preserved.
parent f42b2cf9
......@@ -10,8 +10,10 @@ module Paranoia
def destroy
_run_destroy_callbacks
self[:deleted_at] ||= Time.now
self.save(:validate => false)
self.freeze
# If the instance has already been persisted, then we need to re-save it to flag it as
# destroyed / deleted. We don't require validation in case it causes the updated to fail.
save(:validate => false) if persisted?
freeze
end
alias :delete :destroy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment