active_form_objects 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dsl/polymorphs.rb +3 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cbf0e9447233fffdff5dd16af954f684ad903ccd35caad58363d53282a67e9f
4
- data.tar.gz: e5cb98994f70e13654e514becec81a190f11f05f083287f38b38777c3fe36df1
3
+ metadata.gz: ca5f16d13a98051602acf2df9d62f65d0928f3c2ca6106138ead07acc8662c6f
4
+ data.tar.gz: 8fcbdf3e85e608f0558baa4d6ecc3497b3025a187045cb8ef7ab4ce1b3f8f16d
5
5
  SHA512:
6
- metadata.gz: 0ace46d36714d2925f86fe6fd94c893d6ffd768ed07cec58ff5bce6853456325f8290aea4ed25911eb3944de2548e64c082c646c57865c7d56409d1579917f30
7
- data.tar.gz: 90a5e250038de9067cec51c45c1f961ef109e0d1e717f4d6171b589f21abfecc30cf2b54233b2b3cf1fe3f9151ccd1308353e61cdd98d9dad140992f953329b6
6
+ metadata.gz: da7a647ffd6216ac8b8cd804e520a36190083ff938ee70f3c2ecafd9ffab1d9ec961913d22a45b5dc6658358e970b14f8c99658b531b672c4ea9aec02543e937
7
+ data.tar.gz: fb251b0ae7067aa8c8c7636acf824a54fa48b51590c7c4793c1dff7eb97ab9d48e5e44347964a01634f72097dccff53c423782438f8d7c7b212da15b269ee98a
@@ -9,7 +9,8 @@ module Dsl
9
9
 
10
10
  class PolymorphValidator < ActiveModel::EachValidator
11
11
  def validate_each(record, attribute, data)
12
- return unless record.try(attribute).try(:id).nil? &&
12
+ return unless record.try(attribute).try(:id).nil? &&
13
+ record.try("#{attribute}_id".to_sym).nil? &&
13
14
  !options[:keys].include?(data['type'].try(:to_sym))
14
15
  record.errors.add(attribute, 'type must be included in the list')
15
16
  end
@@ -38,7 +39,7 @@ module Dsl
38
39
  key: key,
39
40
  types: possible_types
40
41
  }
41
- send(:attributes, key)
42
+ send(:attributes, key, "#{key}_id")
42
43
  end
43
44
  end
44
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_form_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Villeneuve