Rookie Question on Beginners Screencast - Data Store issues


#1

Hey everyone, so I’m following the screencast for creating beginner app in the Guides section. I’m run into an issue when I create the App.Store and the App.PostsRoute. When I have the App.Store, nothing in my App shows up on the index page. When I comment out the App.Store, I have access to the index and the “Abouts” page but the “posts” page times out. When I comment out the App.PostsRoute also, I can access all, but handlebar variables in the Posts code obviously doesn’t display. Any ideas as to what’s wrong w/ the App.Store? Here is my code:

App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
});

I’ve tried multiple variations of the revision but as far as I can tell it still is 12. I’ve tried 1.0.0-rc.2 but no luck. Also here is the code for my App.PostsRoute:

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

Any direction would be very appreciated. If this isn’t the place to be posting this, please let me know.


#2

Two things you might try try:

  1. Open up your browser’s developer tools (typically using F12 on WebKit browsers) if you haven’t already. Click on the console tab and see if there are any errors. This kind of “blank app” problem is often linked to an error on the console, at least in my experience.
  2. If that fails, can you post your code, either as a gist on GitHub, or as a jsFiddle? This would allow somebody else to try debugging the problem.

#3

Thanks for the next steps. I opened up the error console and I’m getting two errors.

ReferenceError: Can't find variable: DS                                app.js:3
Error: assertion failed: The route posts was not found   ember-1.0.0-rc.2.js:52

I put the app.js code in fiddle (http://jsfiddle.net/BW2Hr/) any further assistance would be much appreciated.


#4

See that error about “Can’t find variable: DS”?

It sounds like you were missing your copy of ember-data.js. I’ve updated the jsFiddle to run correctly. Note especially the “External Resources” tab in the left-hand column which lists all the JavaScript libraries I used to make it work (except jQuery, which is on the “Frameworks & Extensions” tab).

When making a jsFiddle in the future, please also include the Handlebars templates in the HTML window at the top of screen. I made some quick and dirty templates for you, so no worries this time. :smile:

I hope this helps!


#5

Yeah, it hit me I might be missing some .js file and I noticed that in the starter kit it doesn’t include the ember-data.js file. Where can I get that?

Edit: Who should I notify of the missing ember-data.js in the starter pack? I grabbed the one you were using in the jsFiddle, but for future reference, where is that “officially” located on ember website?


#6

I’m running into a similar issue. I’m having trouble while trying to render the posts template dynamically.

I created a gist with my app.js and index.html code. The problem happens between 8:34 to 10:30 in the “Building an App with Ember.js” screencast.


#7

The ember data file is located at https://github.com/emberjs/data/downloads


#8

Hey Ben, a few questions for you, as far as I know, you don’t need to create the var attr, I would take that variable out. Also, it looks like you’ve included the following in your index file

<script src="js/libs/ember-data-master.js"></script>
<script src="js/libs/showdown.js"></script>
<script src="js/libs/moment.js"></script>

Do you actually have these in your libs folder or did you just included them? I’d take out showdown and moment and head over to the jsFiddle emk gave above and download the ember-data in the external resources. So instead of having the /ember-data-master it will look like

<script src="js/libs/ember-data-a29070da.js"></script>

It’s working just fine for me now that I actually have the ember-data js file. Still would like to know where it’s publicly available.


#9

I believe they’ve intentionally left out the Ember Data file because it’s still not quite ready for production. At this point it’s just experimental. Ember.js isn’t dependent on Ember Data. Robin Ward of Discourse wrote a good blog post on Ember without Ember Data a few weeks ago.


#10

The var attr = DS.attr is just a way of refactoring my code. I’m pretty sure that’s not the issue. I tried it without the variable assignment and it still doesn’t work.

I think my issue has to do with Ember Data. What Ember Data file did you end up using?

I do have all those files in the libs directory.


#11

The one that is provided here , just right click and save. Place it in your libs folder and rename from the ember-data-master to the correct file name.


#13

Another gotcha I ran into - if you’re using DS.FixtureAdapter you need to have some Fixtures defined!