fields-serializer 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f80be5e786d1501f5a9e0ba38d57ad04c7ddb09
|
4
|
+
data.tar.gz: 2e602a2c435ff85ba2c7f42dbc665e3a2676ecc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee25ff226d3e11803fc0f824c97b4d25b277fe355ad8ce6b5645f6b1eac1e1a28dacd566435a8ac3d5cd868bac1d21b53077c83be749247ac5cee071077e20e
|
7
|
+
data.tar.gz: bd57aed56ed96dca607780cc55f2dd860895bf1a070a651100d6b0597b6f25dc3c6e0b039448f240e023ceb045c21992a804b8bc3301f8cbb164d783e3190ebe
|
@@ -29,6 +29,7 @@ module Fields
|
|
29
29
|
def deep_errors(*association_keys)
|
30
30
|
association_keys.inject(errors.to_h) do |error_tree, association_key|
|
31
31
|
associate = send(association_key)
|
32
|
+
associate = associate.to_a if self.class.reflections[association_key.to_s].collection?
|
32
33
|
error_tree.merge!(association_key => __associate_errors(associate))
|
33
34
|
end
|
34
35
|
end
|
@@ -42,8 +43,8 @@ module Fields
|
|
42
43
|
# { "xxx-xxxxxxxx-xxx-xxxxxx" => { name: ["can't be blank"], age: ["can't be less than 18"] },
|
43
44
|
# "0" => { name: ["can't be blank"], age: ["can't be less than 18"] },
|
44
45
|
def __associate_errors(associate)
|
45
|
-
if associate.
|
46
|
-
associate.map.with_index { |object, i| [object.id || i, object.errors.to_h] }.to_h
|
46
|
+
if associate.kind_of?(Array)
|
47
|
+
associate.to_a.map.with_index { |object, i| [object.id || i, object.errors.to_h] }.to_h
|
47
48
|
else
|
48
49
|
associate.errors.to_h
|
49
50
|
end
|