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
700404ee
Commit
700404ee
authored
May 27, 2011
by
Ryan Bigg
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10 from asanghi/readme
Readme + only_deleted scope
parents
7e9adb2a
c3e840e8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
README.md
+11
-0
lib/paranoia.rb
+6
-0
test/paranoia_test.rb
+11
-0
No files found.
README.md
View file @
700404ee
...
...
@@ -60,6 +60,16 @@ If you want a method to be called on destroy, simply provide a _before\_destroy_
...
end
You can replace the older acts_as_paranoid methods as follows:
find_with_deleted(:all) # => unscoped
find_with_deleted(:first) # => unscoped.first
find_with_deleted(id) # => unscoped.find(id)
find_only_deleted(:all) # => only_deleted
find_only_deleted(:first) # => only_deleted.first
find_only_deleted(id) # => only_deleted.find(id)
## License
This gem is released under the MIT license.
\ No newline at end of file
lib/paranoia.rb
View file @
700404ee
...
...
@@ -5,6 +5,12 @@ module Paranoia
module
Query
def
paranoid?
;
true
;
end
def
only_deleted
unscoped
{
where
(
"deleted_at is not null"
)
}
end
end
def
destroy
...
...
test/paranoia_test.rb
View file @
700404ee
...
...
@@ -71,6 +71,17 @@ class ParanoiaTest < Test::Unit::TestCase
assert_equal
1
,
model
.
class
.
unscoped
.
count
end
def
test_only_deleted_scope_for_paranoid_models
model
=
ParanoidModel
.
new
model
.
save
model
.
delete
model2
=
ParanoidModel
.
new
model2
.
save
assert_equal
model
,
ParanoidModel
.
only_deleted
.
last
assert_equal
false
,
ParanoidModel
.
only_deleted
.
include?
(
model2
)
end
private
def
get_featureful_model
FeaturefulModel
.
new
(
:name
=>
"not empty"
)
...
...
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