title: Handling Validation Errors in Ember.js
body: <p>I have a rails app serving json to an ember frontend.</p>
  
  <p>I am trying to display validation errors from on a form on the client.</p>
  
  <p>Rails is returning this json:</p>
  
  <pre><code>{"errors":{"hometown":["is too long (maximum is 64 characters)"]}}
  </code></pre>
  
  <p>In my handlebars template for the current route I am attempting to iterate through the errors but I don't get any output for the errors section:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;label&gt;Hometown&lt;/label&gt;
    {{#each errors.hometown}}
      {{this}}
    {{/each}}
    {{input type="text" class="form-control" valueBinding="effectiveUser.hometown" disabled=entryNotAllowed size="50"}}
  &lt;/div&gt; 
  </code></pre>
  
  <p>I also updated my RESTadapter based on this blog: <a href="https://marcqualie.com/2014/04/model-errors-in-emberjs" rel="nofollow">https://marcqualie.com/2014/04/model-errors-in-emberjs</a>  to include:</p>
  
  <pre><code>  ajaxError: function(jqXHR) {
      var error = this._super(jqXHR);
      if (jqXHR &amp;&amp; jqXHR.status === 422) {
        var jsonErrors = Ember.$.parseJSON(jqXHR.responseText)["errors"];
        return new DS.InvalidError(jsonErrors);
      } else {
        return error;
      }
    }
  </code></pre>
  
  <p>I still really dont understand the context of what this errors object is and why my view has access to it that I but several different sources seem to say this setup should work. Any insight would be appreciated.</p>