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: e2d7eea1eae67d97344677c9e9f61551ac51d688
4
- data.tar.gz: bfd9e2424562e069e9c4c7ae27e87efe3863a3b6
3
+ metadata.gz: 2f80be5e786d1501f5a9e0ba38d57ad04c7ddb09
4
+ data.tar.gz: 2e602a2c435ff85ba2c7f42dbc665e3a2676ecc5
5
5
  SHA512:
6
- metadata.gz: 4eff770dc241f46ef6cee15ded813831ad787ed203b03eeeac7ad7e201ac96967548f7c082cedc29db8eed9942c8eb8b92a3b06e12673ff8a52a0ebe51763821
7
- data.tar.gz: a345685413e0901005840df3dc1dbef0d0c1399950763b1dfef29fd57ad76a8456628b4b2efba0afe1b86fe91fa346be6227b9068b77fd4b490f49066729014b
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.is_a?(ActiveRecord::Associations::CollectionProxy)
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
@@ -1,5 +1,5 @@
1
1
  module Fields
2
2
  module Serializer
3
- VERSION = "0.8.1"
3
+ VERSION = "0.8.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fields-serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Chinery