1

Using the latest (from GitHub today) Ember and Ember Data, this code is giving me an error - Uncaught TypeError: Cannot read property 'find' of undefined at ember-data-latest.js:3170

http://jsfiddle.net/Bf43W/9/

// only needed on JSFiddle; this is to trigger the route
history.pushState("", "", "/projects/1/tasks");

App = Ember.Application.create({});

App.store = DS.Store.extend({
    revision: 4,
    adapter: DS.RESTAdapter.create()
});

App.Project = DS.Model.extend({
    name: DS.attr('string')
});

App.ApplicationController = Ember.ObjectController.extend({
});

App.ApplicationView = Ember.View.extend({
    templateName: 'application'
});

App.TasksView = Ember.View.extend({
    templateName: 'tasks'
});

App.Router = Ember.Router.extend({
    root: Ember.Route.extend({
        tasks: Ember.Route.extend({
            route: '/projects/:project_id/tasks',
            connectOutlets: function(router) {
                router.get('applicationController').connectOutlet('Tasks');
            }
        })
    })
});

App.router = App.Router.create({
    location: 'history'
});

App.initialize(App.router);

Changing :projects_id in the route to something else (e.g. 1, so it matches the URL) fixes this, but of course that's not very useful.

Can anyone shed some light on what's going on here? Thanks!

3 Answers 3

5

I had the same issue. I resolved it by getting the latest download, instead of compiling the latest commit, from:

https://github.com/emberjs/data/downloads

This code is from 3 months ago so we're stuck using a revision 4, but it's stable.

UPDATE

I was able to get to this work after I noticed that the version of Ember they use in the Ember-Data repo is a newer than the version you download from the Ember website:

// Version: v1.0.pre-156-gddcc580
// Last commit: ddcc580 (2012-09-21 09:52:25 -0700)

vs

// Version: v1.0.pre
// Last commit: 7955b85 (2012-08-03 14:50:17 -0700)

After you compile the latest version of Ember-Data, go to into the dist/modules to grab the version of Ember they are developing against.

I also had to change the way that Store is initialized:

App.Store = DS.Store.extend({
  revision: 4,
  adapter: DS.RESTAdapter.create()
});

to

App.store = DS.Store.create({
  revision: 6,
  adapter: DS.RESTAdapter.create()
});

I also had to remove App.initialize() line because this newer version of Ember seems to instantiate itself.

Sign up to request clarification or add additional context in comments.

Comments

3

The only mistake is you have to capitalize the App.store. You declare a class, so the naming convention requires App.Store, in order to let the App initialization going right.

1 Comment

I'd actually do that the other way around: use DS.Store.create() and leave the App.store lowercased.
0

Got the same issue

In my case just replacing

App.Store = DS.Store.extend({
...
})

to

App.store = DS.Store.create({
...
})

fixed it. So I suppose Ember.js version is not an issue. Anyway thank you for idea how to resolve my trouble.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.