lundi 23 novembre 2015

How to handle server-side errors (Rails) on Ember 1.13 app?

Scenario:

I have a Product model on Ember and Rails. I have got the validations working. When I create a new product with a duplicate name, I get a server-side error:

Sample response:

{ "error": 
  { "product_name": [ "has already been taken" ] 
  } 
}

Problem I am facing is, I am unable to show this error on Ember app. Although there are some articles on this, and one thing I have observed is Ember DS.Errors expects the returned object to be 'errors' and not 'error'. But it looks like Standard JSON API format recommends 'error'.

Plus, I am using Grape gem to build the API. So you might wanna have a look at this - http://ift.tt/1MMpEhA

Any suggestions?




Aucun commentaire:

Enregistrer un commentaire