Skip to content

Instantly share code, notes, and snippets.

@ramontayag
Last active August 29, 2015 14:00
Show Gist options
  • Save ramontayag/11337399 to your computer and use it in GitHub Desktop.
Save ramontayag/11337399 to your computer and use it in GitHub Desktop.
App.ApplicationController = Ember.ObjectController.extend
order: null
product: null
init: ->
order_uuid = $('meta[name="order_uuid"]').attr('content')
@store.find("order", order_uuid).then((order) =>
console.log "Yay, got", order
order.get("product").then((product) =>
console.log "sad, did not get", product
# I get this error in the console instead:
# TypeError: Cannot read property 'then' of null
# at http://192.168.33.12:3000/assets/controllers/application_controller.js?body=1:11:38
# at invokeCallback (http://192.168.33.12:3000/assets/ember.js?body=1:9754:19)
# at publish (http://192.168.33.12:3000/assets/ember.js?body=1:9424:9)
# at Promise.publishFulfillment (http://192.168.33.12:3000/assets/ember.js?body=1:9844:7)
# at Object.DeferredActionQueues.flush (http://192.168.33.12:3000/assets/ember.js?body=1:5894:24)
# at Object.Backburner.end (http://192.168.33.12:3000/assets/ember.js?body=1:5985:27)
# at Object.Backburner.run (http://192.168.33.12:3000/assets/ember.js?body=1:6024:18)
# at Object.Ember.run (http://192.168.33.12:3000/assets/ember.js?body=1:6427:26)
# at hash.success (http://192.168.33.12:3000/assets/ember-data.js?body=1:1524:19)
# at fire (http://192.168.33.12:3000/assets/jquery.js?body=1:3100:30)
)
)
DEBUG: Ember : 1.4.0 ember.js?body=1:3462
DEBUG: Ember Data : 1.0.0-beta.7+canary.f482da04 ember.js?body=1:3462
DEBUG: Handlebars : 1.3.0 ember.js?body=1:3462
DEBUG: jQuery : 1.11.0
App.Order = DS.Model.extend
uuid: DS.attr("string")
address: DS.attr("string")
product: DS.belongsTo("product", async: true)
{"order":{"id":2,"uuid":"89069589-5750-41b7-a91e-18da7c03e0c3","product_id":2}}
App.OrderSerializer = DS.RESTSerializer.extend
primaryKey: "uuid"
App.Product = DS.Model.extend
name: DS.attr("string")
orders: DS.hasMany("order", async: true)
{"product":{"id":2,"name":"Secret Guide to Secrets","description":"This is the only book you'll ever need.","order_ids":[1,2]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment