urlTemplate
improves the extesibility of API endpoint urls in RESTAdapter
.
I think that Ember Data has a reputation for being hard to configure. I've often heard it recommended to design the server API around what Ember Data expects.
#!/bin/bash | |
# This takes the maximum forecast between four points surrounding Fairbanks, AK. | |
# Paste this in to https://geojson.io/#map=9/64.5053/-147.4997 to see what those points are. | |
# { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -147, 65 ]}, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -147, 64 ]}, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -148, 65 ]}, "properties": {} }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -148, 64 ]}, "properties": {} } ] } | |
JQ=$(cat <<-JQ | |
{ | |
forecast_time: ."Forecast Time" | fromdateiso8601 | strflocaltime("%H:%M (%Z)"), |
var controller = this; | |
var success = function(model) { | |
controller.transitionToRoute('...'); | |
}; | |
var failure = function(xhr) { | |
controller.get('model').rollback(); | |
if (xhr.status == 400) { | |
controller.showError($.parseJSON(xhr.responseText).detail); |
ApplicationSerializer = DS.RESTSerializer.extend | |
extract: (store, type, payload, id, requestType) -> | |
newPayload = {} | |
newPayload[type.typeKey] = payload | |
@_super store, type, newPayload, id, requestType | |
serializeIntoHash: (hash, type, record, options) -> | |
Ember.merge hash, @serialize record, options |
$ npm --version | |
1.3.21 | |
$ ember --version | |
version: 0.0.37 |
This works with Ember Data 1.0.0-beta.7+canary.b45e23ba, but not Ember Data 1.0.0-beta.8.2a68c63a.
normalizePayload
now takes just a payload.
What is the new way to do this?
require 'spec_helper' | |
describe 'Users' do | |
fixtures :all | |
let(:user) { admin_users(:amiel) } | |
before { login_to_admin } | |
describe '#index' do | |
it 'renders without fail' do | |
visit '/admin/users' |
Object.create({ braces: { make: { it: { slightly: { worse: { each: { time: {} } } } } } } }); | |
return { cursor: "is basically one character off here" }; |
/users/:user_id
).buildURL
(see https://github.com/rjackson/ember-data-nested-urls)MyController = Ember.Controller.extend({ | |
actions: { | |
save: function() { | |
this.get('model').save().then(function() { | |
// Success, maybe transitionToRoute or whatever | |
}, function(xhr) { | |
// Oh noes, we had an error, maybe it's a validation error | |
if (xhr.status == 400) { | |
$.parseJSON(xhr.responseText).each(function(attribute, errors) { | |
this.get('errors').set(attribute, errors); |