Skip to content

Instantly share code, notes, and snippets.

@mars
Last active December 16, 2015 06:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mars/5389148 to your computer and use it in GitHub Desktop.
Save mars/5389148 to your computer and use it in GitHub Desktop.
Add params to Ember Data's RESTAdapter AJAX requests.
App.accountId = 'asdf';
App.RESTAdapter = DS.RESTAdapter.extend({
// Scope all ajax calls.
ajax: function(url, type, hash) {
if (Ember.isEmpty(hash)) hash = {};
if (Ember.isEmpty(hash.data)) hash.data = {};
hash.data.account_id = App.accountId;
this._super(url, type, hash);
}
});
App.Store = DS.Store.extend({
revision: 12,
adapter: "App.RESTAdapter"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment