Skip to content

Instantly share code, notes, and snippets.

@miloops
Created July 30, 2012 15:28
Show Gist options
  • Save miloops/3207801 to your computer and use it in GitHub Desktop.
Save miloops/3207801 to your computer and use it in GitHub Desktop.
class Model
default_scope where(deleted_at: nil)
def destroy_without_callbacks
self.deleted_at = Time.now.utc
update_without_callbacks
end
def destroy
run_callbacks :destroy do
destroy_without_callbacks
end
end
def self.find_with_deleted *args
self.with_exclusive_scope { find(*args) }
end
def deleted?
!deleted_at.nil?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment