Note that there are some explanatory texts on larger screens.

plurals
  1. POEmber Route Incorrectly Treated as a File
    primarykey
    data
    text
    <p>I am working through the Ember tutorial here on Smashing Magazine: <a href="http://coding.smashingmagazine.com/2013/11/07/an-in-depth-introduction-to-ember-js/" rel="nofollow noreferrer">http://coding.smashingmagazine.com/2013/11/07/an-in-depth-introduction-to-ember-js/</a></p> <p>However, when I get to the routing section of their application, it appears that my routing to render a 'users' template is instead making a direct call to a file:</p> <p><img src="https://i.stack.imgur.com/LUz8Z.png" alt="enter image description here"></p> <p>when accessing <code>/index.html#/users</code> with the following app.js file:</p> <p>/* Instantiate the app and set it to log transitions */</p> <pre><code>window.App = Ember.Application.create({ LOG_TRANSITIONS: true }); /* assets/js/app/controllers/users.js */ App.UsersController = Em.ArrayController.extend({ sortProperties: ['name'], sortAscending: true, // false == descending usersCount : function() { return this.get('model.length'); }.property('@each') }); /* user.js */ App.User = DS.Model.extend({ name : DS.attr(), title : DS.attr(), company : DS.attr(), email : DS.attr(), phoneNumber : DS.attr(), streetAddress : DS.attr(), university : DS.attr(), areaOfStudy : DS.attr(), degree : DS.attr(), notes : DS.attr(), lastUpdated : DS.attr() }); /* assets/js/app/router.js */ App.Router.map(function() { this.resource('users', function() { this.resource('user', { path: '/:user_id' }, function() { this.route('edit'); }); this.route('create'); }); }); // each route has this `model` hook where you specify which Model the route needs to load // http://emberjs.com/guides/routing/specifying-a-routes-model/ App.UsersRoute = Ember.Route.extend({ model: function(){ return this.store.find('user'); } }); /* store.js */ App.ApplicationAdaptera = DS.FixtureAdapter; App.User.FIXTURES = [ { id : 1, name : "Dummy data person", title : "something elser", company : "Company 1", email : "somegmail@gmail.com", phoneNumber : "000 000 0000", streetAddress : "middle of no where", university : ["somewhere"], areaOfStudy : ["wow"], degree : ["BS"], notes : "nothing", lastUpdated : "Mon, 26 Aug 2013 22:22:43 GMT" } ]; </code></pre> <p>That is created by concatenating files from the following file structure:</p> <p>Link: <a href="https://i.stack.imgur.com/5Sis9.png" rel="nofollow noreferrer">2</a></p> <p>The template.js file:</p> <pre><code>Ember.TEMPLATES["application"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data /**/) { this.compilerInfo = [4,'&gt;= 1.0.0']; helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; var buffer = '', stack1, hashTypes, hashContexts; data.buffer.push("\n\n\n&lt;div class=\"main\"&gt;\n \n\n \n "); hashTypes = {}; hashContexts = {}; stack1 = helpers._triageMustache.call(depth0, "outlet", {hash:{},contexts:[depth0],types:["ID"],hashContexts:hashContexts,hashTypes:hashTypes,data:data}); if(stack1 || stack1 === 0) { data.buffer.push(stack1); } data.buffer.push("\n\n&lt;/div&gt;"); return buffer; }); Ember.TEMPLATES["index"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data /**/) { this.compilerInfo = [4,'&gt;= 1.0.0']; helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; var buffer = '', stack1, stack2, hashTypes, hashContexts, options, self=this, helperMissing=helpers.helperMissing; function program1(depth0,data) { data.buffer.push(" Got to the users page "); } data.buffer.push("\n\n"); hashTypes = {}; hashContexts = {}; options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),contexts:[depth0],types:["STRING"],hashContexts:hashContexts,hashTypes:hashTypes,data:data}; stack2 = ((stack1 = helpers['link-to'] || (depth0 &amp;&amp; depth0['link-to'])),stack1 ? stack1.call(depth0, "users", options) : helperMissing.call(depth0, "link-to", "users", options)); if(stack2 || stack2 === 0) { data.buffer.push(stack2); } return buffer; }); Ember.TEMPLATES["users"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data /**/) { this.compilerInfo = [4,'&gt;= 1.0.0']; helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; var buffer = '', stack1, hashTypes, hashContexts, self=this; function program1(depth0,data) { var buffer = '', stack1, hashTypes, hashContexts; data.buffer.push("\n &lt;tr&gt;\n &lt;th&gt;"); hashTypes = {}; hashContexts = {}; stack1 = helpers._triageMustache.call(depth0, "user.name", {hash:{},contexts:[depth0],types:["ID"],hashContexts:hashContexts,hashTypes:hashTypes,data:data}); if(stack1 || stack1 === 0) { data.buffer.push(stack1); } data.buffer.push("&lt;/th&gt;\n &lt;/tr&gt;\n"); return buffer; } function program3(depth0,data) { data.buffer.push("\n &lt;tr&gt;\n &lt;th&gt;no users...&lt;/th&gt;\n &lt;/tr&gt;\n"); } data.buffer.push("\n\n&lt;div&gt;Users: "); hashTypes = {}; hashContexts = {}; stack1 = helpers._triageMustache.call(depth0, "usersCount", {hash:{},contexts:[depth0],types:["ID"],hashContexts:hashContexts,hashTypes:hashTypes,data:data}); if(stack1 || stack1 === 0) { data.buffer.push(stack1); } data.buffer.push("&lt;/div&gt;\n&lt;table class=\"table table-bordered table-hover table-condensed\"&gt;\n&lt;thead&gt;\n &lt;td&gt;ID&lt;/td&gt;\n &lt;!--\n &lt;td&gt;Name&lt;/td&gt;\n &lt;td&gt;Title&lt;/td&gt;\n &lt;td&gt;Company&lt;/td&gt;\n &lt;td&gt;Email&lt;/td&gt;\n &lt;td&gt;Phone Number&lt;/td&gt;\n &lt;td&gt;Email&lt;/td&gt;\n &lt;td&gt;Street Address&lt;/td&gt;\n &lt;td&gt;University&lt;/td&gt;\n &lt;td&gt;Area of Study&lt;/td&gt;\n &lt;td&gt;Degree&lt;/td&gt;\n &lt;td&gt;Notes&lt;/td&gt;\n &lt;td&gt;Last Updated&lt;/td&gt;\n --&gt;\n&lt;/thead&gt;\n"); hashTypes = {}; hashContexts = {}; stack1 = helpers.each.call(depth0, "user", "in", "controller", {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),contexts:[depth0,depth0,depth0],types:["ID","ID","ID"],hashContexts:hashContexts,hashTypes:hashTypes,data:data}); if(stack1 || stack1 === 0) { data.buffer.push(stack1); } data.buffer.push("\n&lt;/table&gt;"); return buffer; }); </code></pre> <p>The original handlebars template is:</p> <pre><code>{{! /assets/js/app/templates/users.hbs }} &lt;div&gt;Users: {{usersCount}}&lt;/div&gt; &lt;table class="table table-bordered table-hover table-condensed"&gt; &lt;thead&gt; &lt;td&gt;ID&lt;/td&gt; &lt;!-- &lt;td&gt;Name&lt;/td&gt; &lt;td&gt;Title&lt;/td&gt; &lt;td&gt;Company&lt;/td&gt; &lt;td&gt;Email&lt;/td&gt; &lt;td&gt;Phone Number&lt;/td&gt; &lt;td&gt;Email&lt;/td&gt; &lt;td&gt;Street Address&lt;/td&gt; &lt;td&gt;University&lt;/td&gt; &lt;td&gt;Area of Study&lt;/td&gt; &lt;td&gt;Degree&lt;/td&gt; &lt;td&gt;Notes&lt;/td&gt; &lt;td&gt;Last Updated&lt;/td&gt; --&gt; &lt;/thead&gt; {{#each user in controller}} &lt;tr&gt; &lt;th&gt;{{user.name}}&lt;/th&gt; &lt;/tr&gt; {{else}} &lt;tr&gt; &lt;th&gt;no users...&lt;/th&gt; &lt;/tr&gt; {{/each}} &lt;/table&gt; </code></pre> <p>Index.html file:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;!-- metadata --&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Data Store&lt;/title&gt; &lt;meta name="viewport" content="initial-scale=1"&gt; &lt;!-- stylesheets --&gt; &lt;link rel="stylesheet" href ="assets/css/bootstrap.css"&gt; &lt;link rel="stylesheet" href="assets/css/normalize.css"&gt; &lt;link rel="stylesheet" href="assets/css/style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- templates will be filled in here --&gt; &lt;!-- javascript files loaded after content --&gt; &lt;!-- templates.js, libs.js and app.js are created by a Grunt task --&gt; &lt;script src="assets/js/libs.js"&gt;&lt;/script&gt; &lt;script src="assets/js/templates.js"&gt;&lt;/script&gt; &lt;script src="assets/js/app.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Ember Inspector output:</p> <p><img src="https://i.stack.imgur.com/5Sis9.png" alt="Ember Inspector output"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload