updates for new development env

This commit is contained in:
2021-04-30 15:22:16 -05:00
parent d64772bdfc
commit cf7f5d0f16
8 changed files with 15 additions and 9 deletions
+8 -3
View File
@@ -137,14 +137,19 @@ private
def json_response(obj, options = {})
if obj.is_a?(SimplyStored::Couch)
if obj.errors.present?
json_api_errors = obj.errors.details.map{|key, ers| {id: key, status: '422', title: ers.map{|e| e[:error].to_s}.join(', '), source: {parameter: key}}}
#json_api_errors = obj.errors.details.map{|key, ers| {id: key, status: '422', title: ers.map{|e| e[:error].to_s}.join(', '), source: {parameter: key}}}
json_api_errors = obj.errors.map{|error| {id: error.attribute, status: '422', title: error.message}}
options.reverse_merge(json: {errors: json_api_errors, ok: false}, status: :unprocessable_entity)
else
options.reverse_merge(json: obj)
end
else # assume crude Hash
obj[:ok] = true unless obj.has_key?(:ok)
obj
if obj[:errors]
obj
else
obj[:ok] = true unless obj.has_key?(:ok)
obj
end
end
end