agilibox 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/controllers/concerns/agilibox/api_controller_concern.rb +15 -8
- data/lib/agilibox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75fc12b8fa0262b284e0cfec397b93f50ff588c7d97a43f22ac18c9871aeb621
|
4
|
+
data.tar.gz: c61269d792a2db9eac760af2099713c80efa88a217ea2caea69d5375a7cb7663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5885a20d949ea989c0a48b885d686fc460773008ecf0bd87271d734ef0db59829b923aa8d60ba349f85ff4ee6d96891e324768545c1a000dca89f9c8865f8f
|
7
|
+
data.tar.gz: 4279dc4e03c1db2e15352972f0d7542db527cd749b89b55cae6794e489070fba398341458f7c7fb28adaadff1c34edb14fef0e390b14c3f8ca9360869081010c
|
data/CHANGELOG.md
CHANGED
@@ -14,14 +14,10 @@ module Agilibox::ApiControllerConcern
|
|
14
14
|
|
15
15
|
def render_json_error(any_object, options = {})
|
16
16
|
if any_object.is_a?(ActiveModel::Validations)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
error = model_errors.values.map { |e| e[:full_message] }.join(", ")
|
23
|
-
|
24
|
-
json = {error: error, model_errors: model_errors}
|
17
|
+
json = {
|
18
|
+
:error => json_error_string_for_model(any_object),
|
19
|
+
:model_errors => json_errors_hash_for_model(any_object),
|
20
|
+
}
|
25
21
|
elsif any_object.is_a?(String)
|
26
22
|
json = {error: any_object}
|
27
23
|
else
|
@@ -33,6 +29,17 @@ module Agilibox::ApiControllerConcern
|
|
33
29
|
render_json(json, options)
|
34
30
|
end
|
35
31
|
|
32
|
+
def json_errors_hash_for_model(object)
|
33
|
+
object.errors
|
34
|
+
.map { |a, m| [a, message: m, full_message: object.errors.full_message(a, m)] }
|
35
|
+
.uniq(&:first)
|
36
|
+
.to_h
|
37
|
+
end
|
38
|
+
|
39
|
+
def json_error_string_for_model(object)
|
40
|
+
json_errors_hash_for_model(object).values.map { |e| e[:full_message] }.join(", ")
|
41
|
+
end
|
42
|
+
|
36
43
|
def render_not_found
|
37
44
|
render_json_error t("errors.not_found"), status: :not_found
|
38
45
|
end
|
data/lib/agilibox/version.rb
CHANGED