Take the 2-minute tour ×

I'm planning on using ember.js, however my REST api doesn't exactly align with the packaged REST Adapter. I would like to "override" find and be able to put my own ajax in it. I dislike how an ember findAll retrieves all my documents with no options for pagination, so that along with other query parameters would be useful --which is why I want to write my own ajax. I've been unable to find any documentation on how I would go about doing this.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

You extend one of the Ember Data Adapters. Then you either set the adapter for your application, if you plan on using it sitewide, or you set it for a specific model if you plan on just using it for that model.

If your just feel like modifying one of the methods, extend the RESTAdapter (I assume you are talking about Ember Data) and just define findAll and use your adapter instead of the restadapter.

This is up to date as of Ember Data 1.0 beta 4.

App.NotesAdapter = DS.RESTAdapter.extend({
  find: function(store, type, id) {
    // Do your thing here
    return this.ajax(this.buildURL(type.typeKey, id), 'GET');

  findAll: function(store, type, sinceToken) {
    // Do your thing here
    var query;

    if (sinceToken) {
      query = { since: sinceToken };

    return this.ajax(this.buildURL(type.typeKey), 'GET', { data: query });

  findQuery: function(store, type, query) {
    // Do your thing here

  findMany: function(store, type, ids, owner) {
    return this.ajax(this.buildURL(type.typeKey), 'GET', { data: { ids: ids } });

To see the complete api you can override see: http://emberjs.com/api/data/classes/DS.RESTAdapter.html

share|improve this answer
You don't need revision: 13 –  Gevious Jul 30 '13 at 6:16
Thanks, I actually use ember model instead of ember-data so I'm unfamiliar with the store etc. –  kingpin2k Jul 30 '13 at 14:23
This is great, are those all the methods implemented in Ember.Adapter? I cant find any for ember data. Just the methods used in like basic adapter, or would I roll out completely new methods? Wheres the documentation for ember-data? –  carboncomputed Jul 30 '13 at 14:41
add comment

I had the same problem. I too wanted to use a slightly different format with my backend (cakePHP) and could not figure out how to do it. The previous answers are great but you might not need to redefine every method but simply change the format of the URL by overriding the buildURL in the RESTAdapter.

For example, I want to use cakePHP's extension and want my urls to looks like so, application wide:

  • /users.json (findAll)
  • /users/view/1.json (find)
  • /users/delete/1.json
  • /users/edit.json (POST)
  • /users/add.json (POST)

After much hair pulling and the realization that ember-data is essential I used the following code:

App.ApplicationAdapter = DS.RESTAdapter.extend({
  buildURL: function(type, id) {
    var url = '/' + this.pluralize(type.typeKey);

    if (id) {
        url += '/' + id;

    url += '.json';

    return url;

Ember's docs are good, but most of their examples use FIXTURE data. I wish they had a simple example how to write different types of adapters for different situations.

share|improve this answer
how did you solve HTTP method substitution in your case? I mean "/users/edit.json (POST)". Default ember HTTP method for modify is PUT. –  Oleksandr_DJ Oct 30 '13 at 7:46
add comment

Your Answer


