diff --git a/packages/activemodel-adapter/lib/system/active-model-adapter.js b/packages/activemodel-adapter/lib/system/active-model-adapter.js index 8c9bb9b201e..24fbcb5b0d7 100644 --- a/packages/activemodel-adapter/lib/system/active-model-adapter.js +++ b/packages/activemodel-adapter/lib/system/active-model-adapter.js @@ -6,6 +6,7 @@ import {pluralize} from "ember-inflector"; @module ember-data */ +var camelize = Ember.String.camelize; var decamelize = Ember.String.decamelize; var underscore = Ember.String.underscore; @@ -143,6 +144,16 @@ var ActiveModelAdapter = RESTAdapter.extend({ if (jqXHR && jqXHR.status === 422) { var response = Ember.$.parseJSON(jqXHR.responseText); var errors = response.errors ? response.errors : response; + + for (var underscoredError in errors) { + var camelizedError = camelize(underscoredError); + + if (camelizedError !== underscoredError) { + errors[camelizedError] = errors[underscoredError]; + delete errors[underscoredError]; + } + } + return new InvalidError(errors); } else { return error;