-
-
Save bbonamin/3207933 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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