Skip to content

Commit

Permalink
fix some destroy/restore edge cases with ActiveRecord 2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Oct 14, 2009
1 parent 72d2386 commit 4a9ae5a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/is_paranoid.rb
Expand Up @@ -44,7 +44,8 @@ def self.find_with_destroyed *args

# Mark the model deleted_at as now.
def destroy_without_callbacks
self.update_attribute(:deleted_at, Time.now.utc)
self.deleted_at = Time.now.utc
update_without_callbacks
end

# Override the default destroy to allow us to flag deleted_at.
Expand All @@ -62,7 +63,9 @@ def destroy
# Set deleted_at flag on a model to nil, effectively undoing the
# soft-deletion.
def restore
self.update_attribute(:deleted_at, nil)
self.deleted_at_will_change!
self.deleted_at = nil
update_without_callbacks
end
end
end
Expand Down

0 comments on commit 4a9ae5a

Please sign in to comment.