Model weirdness


#1

If I define in my route a model:

App.PhotoRoute = Ember.Route.extend({
  model: function(params) {
    return this.store.find('photo', params.photo_id);
  }
});

and this code goes off to the server to fetch that photo because I am using a RESTAdapter…

Should I expect that photo to be pushed into the store? As in - when I go into the ember tab in chrome and navigate to Data - should I expect to see it there?

Basically - as you can probably guess - I cannot. I am stumped however as it used to work like this I am pretty sure.

What would cause this to happen?

if you would like an example see here:

http://test.sonatribe.co.uk:8080/event/glastonbury-2013

There is data being loaded from my route but in the ember console there is no data!

Is this because I am using the latest ember-data perhaps?

DEBUG: ------------------------------- 
DEBUG: Ember      : 1.8.0 
DEBUG: Ember Data : 1.0.0-beta.11 
DEBUG: Handlebars : 1.3.0 
DEBUG: jQuery     : 1.11.1
DEBUG: -------------------------------

#2

Yes, you should see a record in the Ember Inspector after that code executes. It sounds like maybe the format of the JSON coming from your back end might not be what Ember Data is expecting. Compare what your server is sending back with what you can generate here: http://andycrum.github.io/ember-data-model-maker/ and look for any discrepancies.


#3

But the data loads. You can see it on screen. Surely if the JSON was wrong it wouldn’t even show?


#4

That project does look v interesting though!


#5

Can you please show us your DS.Model definition of App.Photo ?


#6

I guess I’m confused: you’re saying that the data loads, and the record displays on screen, but there’s nothing in the Ember Inspector? Is there anything at all in the Ember Inspector (View Tree, Routes, etc)?


#7

@MrMcDowall - you can see from the demo link: http://test.sonatribe.co.uk:8080/event/glastonbury-2013 - the data loads, the routes are all there - just no data…


#8

At first try to fix this:

Uncaught Error: Assertion Failed: You cannot use the same root element (body) multiple times in an Ember.Application

#9

Yeah - I have no idea what the hell is causing that - has anyone seen that before?

I am definitely not creating more than one application:

So it’s not that

It is failing in Setup()

At this line:

Ember.assert(fmt('You cannot use the same root element (%@) multiple times in an Ember.Application', [rootElement.selector || rootElement[0].tagName]), !rootElement.is('.ember-application'));

So it is saying that before it can run setup it has already been setup… and setting a breakpoint here does indeed break twice… What would be causing that? The run loop makes it hard to see where these calls are coming from


#10

I think that problem might be in your HTML file.

try to add something like this after tag

<div id="thisisuniqueid"></div>

and define root element in Ember.Application.create

App = Ember.Application.create({
    rootElement: '#thisisuniqueid', .....