Skip to content

Instantly share code, notes, and snippets.

@ksol
Created October 18, 2015 14:47
Show Gist options
  • Save ksol/b6d495109ede207c68e2 to your computer and use it in GitHub Desktop.
Save ksol/b6d495109ede207c68e2 to your computer and use it in GitHub Desktop.
import UrlTemplates from "ember-data-url-templates";
export default DS.RESTAdapter.extend(UrlTemplates, {
urlTemplate: '{+host}/posts/{postId}/comments{/id}',
findUrlTemplate: '{+host}/comments/{id}',
createRecordUrlTemplate: '{+host}/users/{userId}/comments',
currentUser: Ember.inject.service(),
urlSegments: {
postId(type, id, snapshot, query) {
return snapshot.belongsTo('post', { id: true });
},
userId() {
return this.get('currentUser.id');
}
}
});
@GabrielCW
Copy link

I fixed a small typo in my fork, if you're interested: https://gist.github.com/GabrielCW/da2c95ace69913885513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment