validation_errors 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +2 -2
- data/README.md +5 -2
- data/lib/validation_error.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fed7190ae44232b3441ccaa634450ceefa80ac74dd5615c6b0b58147fc3990d
|
4
|
+
data.tar.gz: 3fc056004f5e810c75489c009df26d2bd42f3804d163b3c2bcd2ab85665a50e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2fd1b962e6f1dca4fa2cdb6dc672bc45823d1e79e20a1ccbe44f5dc562207e7871c1f5637acfb8698af7c54caad3be70de5b80f44d5bdab501d76825522d11c
|
7
|
+
data.tar.gz: 15191622d27d105d9872cd266b9610e6c8e6db98c650aefb0efcd0ef9d833ec1f6ebe00fc7ef101443abac6c959bd099dcc6cc426a0434505bb3653ce6f53d02
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
validation_errors (0.
|
4
|
+
validation_errors (0.2.0)
|
5
5
|
activerecord (>= 4.1.0)
|
6
6
|
zeitwerk (>= 2.0.0)
|
7
7
|
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
tzinfo (2.0.5)
|
53
53
|
concurrent-ruby (~> 1.0)
|
54
54
|
unicode-display_width (2.3.0)
|
55
|
-
zeitwerk (2.6.
|
55
|
+
zeitwerk (2.6.6)
|
56
56
|
|
57
57
|
PLATFORMS
|
58
58
|
arm64-darwin-21
|
data/README.md
CHANGED
@@ -72,7 +72,10 @@ def create
|
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
|
-
Yes, this will execute an
|
75
|
+
Yes, this will execute an additional INSERT into your database. Keep it in mind.
|
76
|
+
|
77
|
+
`ValidationError.track(@model)` will automatically detect if the action is `create` or `update`.
|
78
|
+
You can also use a custom action name by calling `ValidationError.track(@model, action: 'custom_action')`.
|
76
79
|
|
77
80
|
### Automatic
|
78
81
|
|
@@ -173,7 +176,7 @@ or, if you have the view above:
|
|
173
176
|
|
174
177
|
```sql
|
175
178
|
select invalid_model_name, error_column, count(*)
|
176
|
-
from
|
179
|
+
from flat_validation_errors
|
177
180
|
group by 1, 2
|
178
181
|
```
|
179
182
|
|
data/lib/validation_error.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ValidationError < ActiveRecord::Base
|
4
|
-
def self.track(invalid_model)
|
4
|
+
def self.track(invalid_model, action: invalid_model.persisted? ? "update" : "create")
|
5
5
|
create!(invalid_model_name: invalid_model.class.name,
|
6
6
|
invalid_model_id: invalid_model.id,
|
7
7
|
details: invalid_model.errors.details,
|
8
|
-
action:
|
8
|
+
action: action)
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validation_errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|