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
a3179441
Commit
a3179441
authored
Mar 16, 2014
by
Sammy Larbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure uniqueness validation is scoped by deleted_at
Fixes #114
parent
6b6efeec
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
lib/paranoia.rb
+13
-0
No files found.
lib/paranoia.rb
View file @
a3179441
...
@@ -237,3 +237,16 @@ class ActiveRecord::Base
...
@@ -237,3 +237,16 @@ class ActiveRecord::Base
end
end
require
'paranoia/rspec'
if
defined?
RSpec
require
'paranoia/rspec'
if
defined?
RSpec
module
ActiveRecord
module
Validations
class
UniquenessValidator
<
ActiveModel
::
EachValidator
protected
def
build_relation_with_paranoia
(
klass
,
table
,
attribute
,
value
)
relation
=
build_relation_without_paranoia
(
klass
,
table
,
attribute
,
value
)
relation
.
and
(
klass
.
arel_table
[
klass
.
paranoia_column
].
eq
(
nil
))
end
alias_method_chain
:build_relation
,
:paranoia
end
end
end
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