Fix product images
This commit is contained in:
@@ -132,6 +132,22 @@ private
|
||||
end
|
||||
end
|
||||
|
||||
# General handler of json responses. Will be able to set some additional communication data.
|
||||
# By default a response is ok.
|
||||
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}}}
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
def force_reloads
|
||||
load Rails.root.join('config/initializers/custom_form_builder.rb')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user