formwandler 0.1.1 → 0.1.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/formwandler/form.rb +3 -2
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 476eb8a281a8d6624f206d805b0c1db600026441
4
- data.tar.gz: 8ec883f656ab7c7d13f450eae11fcd0ed8763744
3
+ metadata.gz: 0db28341ef76b8524fd9d0bc11b243667f490f08
4
+ data.tar.gz: c263b0a3736ed877b25d7648a175b15fd13053c5
5
5
  SHA512:
6
- metadata.gz: f1f59bfe610bacd695b70e34c698fb0c24f1a6e40b7fc92ee8858062cd65cdcc3699280ab0b1bf34b88f32a08cf8e00ac0bb94e0afd838173d7bf387f8a20c57
7
- data.tar.gz: d85dd4008af8a61d01f062559e786a0734d46cbf5d9da576005d1fc34e7281a14beda0bc3ecb9e65b571e8b5d6e784f33b3fcbf8000fc82baa280174475c8596
6
+ metadata.gz: 3bd276f0a797234bdcd978948c6c0036b06b9fbf828671f7c95180935866933caddcc4b08e131e07a8fadc8a38393d5b65d2ac49316c6430c01d7ec717fa74b5
7
+ data.tar.gz: 4846d5deb2a856e3e6ce63f0020e7dc7876f1fb6bb444c357bc73cc1e237a91b16ee99d27a24effd15247d93126714321394b37274e0a2513f2abc4873f3afb5
@@ -85,6 +85,7 @@ module Formwandler
85
85
  all_valid = true
86
86
  models.each do |name, model|
87
87
  all_valid = false if model.invalid?
88
+ next if model.valid?
88
89
  fields_for_model(name).each do |field|
89
90
  model.errors[field.source].each do |error_message|
90
91
  errors.add(field.name, error_message)
@@ -119,7 +120,7 @@ module Formwandler
119
120
 
120
121
  def save_models!
121
122
  models.sort_by do |(name, _model)|
122
- self.class.model_save_order.index(name) || self.class.model_save_order.size
123
+ self.class.model_save_order&.index(name) || self.class.model_save_order&.size
123
124
  end.map(&:last).compact.each(&:save!)
124
125
  end
125
126
 
@@ -129,7 +130,7 @@ module Formwandler
129
130
 
130
131
  def permitted_params(params)
131
132
  visible_fields = fields.reject(&:hidden?).map(&:name)
132
- delocalizations = fields.transform_values(&:delocalize).compact
133
+ delocalizations = fields.map(&:delocalize).compact
133
134
  params = ActionController::Parameters.new(params) if params.is_a?(Hash)
134
135
  params.require(model_name.param_key).permit(*visible_fields).delocalize(delocalizations)
135
136
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formwandler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Bilharz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-06 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: delocalize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement