Created
January 7, 2017 23:21
-
-
Save wojtha/ba08912d8fcdea4e6fbf75a5fd346d6f to your computer and use it in GitHub Desktop.
Implementing soft deletes in Rails, source: http://patrikonrails.com/posts/3
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 Comment < ApplicationRecord | |
| default_scope -> { where(deleted_at: nil) } | |
| def soft_delete | |
| update(deleted_at: Time.current) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment