I am trying to create an Ember.js application for the first time using a RESTful backend. I have been always been using HTML rendered from my server and hence I am a newbie to ember. I have a query to fetch a restaurant based on owner id and then show the name in the title bar.
LiveKitchen.RestaurantController = Ember.ObjectController.extend({
needs : 'login'
});
LiveKitchen.RestaurantRoute = Ember.Route.extend({
model: function() {
console.log(this.controllerFor('login').get('user_id'));
console.log('Fetching Restaurants ' + this.store.find('restaurant', {owner_id : this.controllerFor('login').get('user_id')}));
var res = this.store.find('restaurant', {owner_id : this.controllerFor('login').get('user_id')});
// restaurant.tables = this.store.find('table', {restaurant_id : restaurant.mongo_id});
console.log('Restaurant ' + res);
return res.objectAt(0);
// return restaurant;
}
});
I have verified the response using the debugger and seen that the json data is returned correctly. However my template
<script type="text/x-handlebars" data-template-name="restaurant">
<small>
<i class="icon-leaf"></i>
{{name}}
</small>
</script>
doesn't have the name printed in the page.
Can you please help me on how I can debug this and figure out why the data is not rendering? Since there are no errors, I am not able to find out what step to take next.
this.store.find('restaurant')
returning more than one instance of the restaurant model? – NicholasJohn16