Skip to main content

Ben Cromwell

REST URL schemes in Ember

In Ember, the default is for the name of your model corresponds to a REST route of the same name.

So what happens when you’re using hyphens in the URL? You can’t name your model to match, but the solution is quite simple, although it did take me a lot of searching before finding it.

    App.Store = DS.Store.extend({
        revision: 1,
        adapter: DS.RESTAdapter.extend({
            namespace: 'api',
            pathForType: function (type) {
                return Ember.String.dasherize(type);
            }
        })
    });

More info on connecting to an HTTP server in Ember is here.