dockyard/ember-appkit-rails — pull request #166 by HeroicEric (2014-01-23 17:18:44+00:00)
Title: Scaffold generated controller - Match error response expected by ember-data.js

I'm not sure if the end result here is better or worse but I wanted to bring up the issue.

The Rails controller that is generated when using the scaffold generator does not return the errors formatted in the way that ember-data is expecting [here](https://github.com/emberjs/data/blob/master/packages/activemodel-adapter/lib/system/active_model_adapter.js#L84-L120).

A response returning `{ "name": ["can't be blank"] }` results in the following error:

```
POST http://localhost:3000/api/v1/monsters 422 (Unprocessable Entity) jquery.js?body=1:8707

Uncaught TypeError: Object.keys called on non-object ember-data.js?body=1:9584
```

A response returning `{ "errors": { "name": ["can't be blank"] } }`, fixes the previous error but still results in the following error:

```
POST http://localhost:4000/api/v1/monsters 422 (Unprocessable Entity) application-2ddd26bf1651a818b350823f9ecf0fa7.js:3

Error: The backend rejected the commit because it was invalid: {name: can't be blank}
at new Error (native)
at Error.DS.InvalidError (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:13:22737)
at DS.ActiveModelAdapter.DS.RESTAdapter.extend.ajaxError (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:14:3109)
at n [as ajaxError] (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:4:7860)
at r.error (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:13:29974)
at h (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:2:3879)
at Object.d.fireWith (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:2:4686)
at n (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:3:14369)
at XMLHttpRequest.n (http://localhost:4000/assets/application-2ddd26bf1651a818b350823f9ecf0fa7.js:3:20095)
```

Like I said, I'm not sure which one is better or if there is a better way to handle this but I wanted to bring it up.

Any thoughts?