ember.js - Ember error when json response root key is singular -
i getting ember error when response json root singular.
json response:
{"subscription": {"id": "1"}} error:
assertion failed: server returned hash key subscription have no mapping it
model:
app.subscription if pass plural root key subscriptions in json response, works fine. don't think should have though since singular version default behavior active _model_serializers if there 1 resource send.
is bug in ember or should doing supported?
what might define plurals on adapter. in case of model called app.subscription this:
app.adapter = ds.restadapter.extend(); app.adapter.configure('plurals', { "subscription": "subscription" }); edit
as .json 1 possible solution might hook buildurl function of restadapter , adding .json suffix yourself. this:
app.adapter = ds.restadapter.extend({ buildurl: function(record, suffix) { var url = this._super(record, suffix); return url + ".json"; } }) this make request http://localhost:4000//subscription.json
hope helps.
Comments
Post a Comment