deep_unrest 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/deep_unrest/application_controller.rb +14 -8
- data/lib/deep_unrest/version.rb +1 -1
- data/lib/deep_unrest.rb +3 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9cfbdaef1aa33d938ddab66e9fc2f6ad141fcb3
|
4
|
+
data.tar.gz: 304b75b0f0dbadac905ccfd0724266f94bba1fcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49b0b0f3783a2031445fd06582c5c21a5e6d30bd2f58cab76c7258106f5f1fe09056ae1a39c87fb9ae5602e1d1a520662a1b631f60ce92570a69eeedd7458eae
|
7
|
+
data.tar.gz: ca22b5fc8ba5cdc32c071e97c41a94a5732009c6f84e163763b2243b4f130abc0abf70f2adee66fbe9e5808351f930690548ca6d1d2d60438a18d2c125c822f2
|
@@ -6,19 +6,25 @@ module DeepUnrest
|
|
6
6
|
{ current_user: current_user }
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
#
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
# rails can't deal with array indices in params (converts them to hashes)
|
10
|
+
# see https://gist.github.com/bloudermilk/2884947
|
11
|
+
def repair_nested_params(obj)
|
12
|
+
obj.each do |key, value|
|
13
|
+
if value.is_a?(ActionController::Parameters) || value.is_a?(Hash)
|
14
|
+
# If any non-integer keys
|
15
|
+
if value.keys.find { |k, _| k =~ /\D/ }
|
16
|
+
repair_nested_params(value)
|
17
|
+
else
|
18
|
+
obj[key] = value.values
|
19
|
+
value.values.each { |h| repair_nested_params(h) }
|
20
|
+
end
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
25
|
def update
|
20
26
|
redirect = allowed_params[:redirect]
|
21
|
-
data =
|
27
|
+
data = repair_nested_params(allowed_params[:data])
|
22
28
|
redirect_replace = DeepUnrest.perform_update(data,
|
23
29
|
current_user)
|
24
30
|
resp = {}
|
data/lib/deep_unrest/version.rb
CHANGED
data/lib/deep_unrest.rb
CHANGED
@@ -363,7 +363,8 @@ module DeepUnrest
|
|
363
363
|
errors.map do |key, values|
|
364
364
|
path_info = parse_error_path(key.to_s)
|
365
365
|
operation = scopes.find do |s|
|
366
|
-
s[:type] == path_info[:type] &&
|
366
|
+
(s[:type] == path_info[:type].camelize(:lower) &&
|
367
|
+
s[:index] == path_info[:idx].to_i)
|
367
368
|
end
|
368
369
|
|
369
370
|
format_errors(operation, path_info, values)
|
@@ -390,9 +391,7 @@ module DeepUnrest
|
|
390
391
|
if errors
|
391
392
|
base_key = "#{record.class.to_s.camelize(:lower).pluralize}[#{i}]"
|
392
393
|
errors.keys.map do |attr|
|
393
|
-
|
394
|
-
errors["#{base_key}.#{attr}".to_sym] = errors.delete(attr)
|
395
|
-
end
|
394
|
+
errors["#{base_key}.#{attr}".to_sym] = errors.delete(attr)
|
396
395
|
end
|
397
396
|
end
|
398
397
|
errors
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_unrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lynn Hurley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|