Skip to content

Instantly share code, notes, and snippets.

@SweeD
Last active December 17, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SweeD/5655281 to your computer and use it in GitHub Desktop.
Save SweeD/5655281 to your computer and use it in GitHub Desktop.
DS.RESTAdapter plurals configuration (Ember-Data)
DS.RESTAdapter.configure("plurals",
galleries: "galleries" # If your model is called App.Galleries
gallery: "galleries" # If your model is called App.Gallery
)
@commadelimited
Copy link

This is what my code looks like now, your plurals is the same as the docs and doesn't do anything:

The URL is /#/galleries the call being made to the server is /api/galleriess

    // Application definition
    var App = Ember.Application.create();
    App.Store = DS.Store.extend({
        revision: 12,
        // adapter: 'DS.FixtureAdapter'
        adapter: DS.RESTAdapter.create({
            namespace: 'api'
        })
    });

    DS.RESTAdapter.configure("plurals",{
        galleries: "galleries", // If your model is called App.Galleries
        gallery: "galleries" // If your model is called App.Gallery
    });

    // Routing
    App.Router.map(function() {
        this.resource('galleries');
    });

    App.GalleriesRoute = Ember.Route.extend({
        model: function(){
            return App.Galleries.find();
        }
    });



    // Models
    App.Galleries = DS.Model.extend({
        title: DS.attr('string'),
        thumbnail: DS.attr('string')
    });



    // Controllers
    App.GalleriesController = Ember.ArrayController.extend();



    // Fixture Data
    App.Galleries.FIXTURES = [
        {
            id: 1,
            title: 'Weddings',
            thumbnail: 'https://s3.amazonaws.com/richkphoto/weddings_001_cp.jpg'
        },
        {
            id: 2,
            title: 'Engagements',
            thumbnail: 'https://s3.amazonaws.com/richkphoto/engagements_001_cp.jpg'
        },
        {
            id: 3,
            title: 'Editorial',
            thumbnail: 'https://s3.amazonaws.com/richkphoto/editorial_001_cp.jpg'
        },
        {
            id: 4,
            title: 'Personal',
            thumbnail: 'https://s3.amazonaws.com/richkphoto/personal_001_cp.jpg'
        }
    ];

@SweeD
Copy link
Author

SweeD commented May 27, 2013

Do the configuration block before the DS.RESTAdapter.create.

Switching DS.RESTAdapter.configure( ... and App.Store = DS.Store.extend({ do the trick.

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