Ember can't find find() method on model


Ember can't seem to find the findAll() and find() methods I have implemented on my Property model. Here are the errors I am getting:

TypeError: App.Property.findAll is not a function

and

Error: assertion failed: Expected App.Property to implement `find` for use in 'root.property' `deserialize`. Please implement the `find` method or overwrite `deserialize`.

My router is set up like this:

App.Router = Ember.Router.extend({
    showProperty: Ember.Route.transitionTo('property'),
    root: Ember.Route.extend({
        home: Ember.Route.extend({
            route: '/',
            connectOutlets: function(router) {
                router.get('applicationController').connectOutlet('home', App.Property.findAll());
            }
        }),
        property: Ember.Route.extend({
            route: '/property/:property_id',
            connectOutlets: function(router, property) {
                router.get('applicationController').connectOutlet('property', property);
            },
        }),
    })
});

And here is my model:

App.Property = Ember.Object.extend({
    id: null,
    address: null,
    address_2: null,
    city: null,
    state: null,
    zip_code: null,
    created_at: new Date(0),
    updated_at: new Date(0),
    find: function() {
        // ...
    },
    findAll: function() {
        // ...
    }
});

What am I doing wrong? Should those methods go on the Property model or should they go somewhere else? Should I be override the deserialize() method instead of using find()? But even if I use that workaround findAll() still wouldn't work and I would still get that first error.

Thanks for any help.

The find and findAll methods should be declared in reopenClass, not in extend, because you wants to define class methods, not instance methods. For example:

App.Property = Ember.Object.extend({
    id: null,
    address: null,
    address_2: null,
    city: null,
    state: null,
    zip_code: null,
    created_at: new Date(0),
    updated_at: new Date(0)
});

App.Property.reopenClass({
    find: function() {
        // ...
    },
    findAll: function() {
        // ...
    }
});