File tree 1 file changed +3
-0
lines changed
1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,15 @@ def self.included(klazz)
24
24
module Query
25
25
def paranoid? ; true ; end
26
26
27
+ # If you want to find all records, even those which are deleted
27
28
def with_deleted
28
29
if ActiveRecord ::VERSION ::STRING >= "4.1"
29
30
return unscope where : paranoia_column
30
31
end
31
32
all . tap { |x | x . default_scoped = false }
32
33
end
33
34
35
+ # If you want to find only the deleted records
34
36
def only_deleted
35
37
if paranoia_sentinel_value . nil?
36
38
return with_deleted . where . not ( paranoia_column => paranoia_sentinel_value )
@@ -45,6 +47,7 @@ def only_deleted
45
47
end
46
48
alias_method :deleted , :only_deleted
47
49
50
+ # If you want to restore a record
48
51
def restore ( id_or_ids , opts = { } )
49
52
ids = Array ( id_or_ids ) . flatten
50
53
any_object_instead_of_id = ids . any? { |id | ActiveRecord ::Base === id }
You can’t perform that action at this time.
0 commit comments