0

All my versions:

Ember: 1.9.0
Handlebars: 2.0.0
jQuery: 2.1.3
Ember Data: 1.0.0-beta.12

All I'm trying to do is make a simple Ember Data store.find() call and everything seems to be going horribly wrong. It gets even weirder too. If I wrap this.store.find(...) in a get() call and instead say this.get('store').find(...) I get a completely different error.

Here's the error I'm getting with just this.store.find(...):

Error while processing route: budget Cannot read property 'find' of undefined TypeError: Cannot read property 'find' of undefined
at Application.BudgetRoute.Ember.Route.extend.model (http://localhost/javascript/app/routes/budget.route.js:9:24)
at EmberObject.extend.deserialize (http://localhost/javascript/bower_components/ember/ember.js:24849:21)
at applyHook (http://localhost/javascript/bower_components/ember/ember.js:47575:30)
at Object.HandlerInfo.runSharedModelHook (http://localhost/javascript/bower_components/ember/ember.js:45596:22)
at Object.subclass.getModel (http://localhost/javascript/bower_components/ember/ember.js:45822:21)
at __exports__.bind (http://localhost/javascript/bower_components/ember/ember.js:47449:19)
at tryCatch (http://localhost/javascript/bower_components/ember/ember.js:47898:16)
at invokeCallback (http://localhost/javascript/bower_components/ember/ember.js:47910:17)
at publish (http://localhost/javascript/bower_components/ember/ember.js:47881:11)
at http://localhost/javascript/bower_components/ember/ember.js:29453:9

this.store is undefined here.

Here's the error I'm getting with this.get('store').find(...):

Error while processing route: budget Assertion Failed: Budget has no method `find`. Error: Assertion Failed: Budget has no method `find`.
    at new Error (native)
    at Error.EmberError (http://localhost/javascript/bower_components/ember/ember.js:13740:23)
    at Object.Ember.assert (http://localhost/javascript/bower_components/ember/ember.js:3902:15)
    at Object.EmberObject.extend.store.computed.find (http://localhost/javascript/bower_components/ember/ember.js:24892:19)
    at Application.BudgetRoute.Ember.Route.extend.model (http://localhost/javascript/app/routes/budget.route.js:9:32)
    at EmberObject.extend.deserialize (http://localhost/javascript/bower_components/ember/ember.js:24849:21)
    at applyHook (http://localhost/javascript/bower_components/ember/ember.js:47575:30)
    at Object.HandlerInfo.runSharedModelHook (http://localhost/javascript/bower_components/ember/ember.js:45596:22)
    at Object.subclass.getModel (http://localhost/javascript/bower_components/ember/ember.js:45822:21)
    at __exports__.bind (http://localhost/javascript/bower_components/ember/ember.js:47449:19)

This time it finds this.store, but the Budget model has no find() method on it (and no where on the internet are there instructions that say there should be...)

budget.route.js:

define([
  'ember',
  'application',
  'controllers/budget.controller',
  'views/budget.view'
], function(Ember, Application) {
  Application.BudgetRoute = Ember.Route.extend({
    model: function(params) {
      return this.store.find('budget', params.budget_key);
    }
  });

  return Application.BudgetRoute;
});

My Budget model:

define([
  'ember-data',
  'application'
], function(DS, Application) {
  Application.Budget = DS.Model.extend({
    budget_key: DS.attr(),
    user: DS.attr(),
    title: DS.attr(),
    description: DS.attr(),
    picture: DS.attr(),
    order: DS.attr(),
    created: DS.attr()
  });

  return Application.Budget;
});

My ApplicationAdapter:

define([
  'ember-data',
  'application',
  'models/budget'
], function(DS, Application) {
  Application.ApplicationAdapter = DS.RESTAdapter.extend({
    namespace: 'api'
  });

  return Application.ApplicationAdapter;
});

I'm also using deferReadiness() and advanceReadiness() if that makes any difference here...

1 Answer 1

0

I am seeing this as well with 1.9.0. Seems that the store is never set up at all, MyApp.__container__.lookup("store:main") is undefined. I spent some time trying to track this down but I think it could be a major rabbit hole and I didn't find any answers.

1.10.0-beta.1 seems to be working however. I know that's not really an answer to your specific question but I hope it's better than nothing in this situation.

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

10 Comments

I tried downgrading to Ember-Data beta.1 and it didn't help. Which versions of Ember and Ember-Data were you referring to?
Here is what I got that ended up working, but I don't think the problem is with Ember-Data--- Ember : 1.9.0 Ember Data : 1.0.0-beta.12 Handlebars : 2.0.0 jQuery : 1.11.2
Hmmm those are the exact versions I have too. No luck though. Where were you able to make this work? Is it online?
Yea it works, but I did run in to plenty of trouble getting handlebars to work with ember cli and emblem. Do you mean that you still have an undefined store after using 1.9.0? I never got that error again myself after 1.9.0.
Hmmm I'm not using ember CLI, just vanilla ember and requirejs for now. Could that be the problem? I've tried every version combination I could think of. Nothing has worked. Another thing is that I'm not actually explicitly declaring my store anywhere because ember is supposed to do it for me. Do I need to do that?
|

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.