Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paranoia
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paranoia
Commits
19ad6c6e
Commit
19ad6c6e
authored
Dec 18, 2013
by
Ryan Bigg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README with more usage examples
parent
a95a67f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
1 deletions
+60
-1
README.md
+60
-1
No files found.
README.md
View file @
19ad6c6e
...
...
@@ -66,7 +66,22 @@ class Client < ActiveRecord::Base
end
```
Hey presto, it's there!
Hey presto, it's there! Calling
`destroy`
will now set the
`deleted_at`
column:
```
>> client.deleted_at => nil
>> client.destroy => client
>> client.deleted_at => [current timestamp]
```
If you really want it gone, call
`destroy`
twice:
```
>> client.deleted_at => nil
>> client.destroy => client
>> client.destroy => client
```
If you want a method to be called on destroy, simply provide a _before
\_
destroy_ callback:
...
...
@@ -102,6 +117,50 @@ def product
end
```
If you want to find all records, even those which are deleted:
```
Client.with_deleted
```
If you want to find only the deleted records:
```
Client.only_deleted
```
If you want to check if a record is soft-deleted:
```
client.destroyed?
```
If you want to restore a record:
```
Client.restore(id)
```
If you want to restore a whole bunch of records:
```
Client.restore([id1, id2, ..., idN])
```
If you want to restore a record and their dependently destroyed associated records:
```
Client.restore(id, :restore => true)
```
If you want callbacks to trigger before a restore:
```
before_restore :callback_name_goes_here
```
For more information, please look at the tests.
## Acts As Paranoid Migration
You can replace the older acts_as_paranoid methods as follows:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment