Last active
August 29, 2015 14:00
-
-
Save ramontayag/11337399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Order = DS.Model.extend | |
uuid: DS.attr("string") | |
address: DS.attr("string") | |
product: DS.belongsTo("product", async: true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"order":{"id":2,"uuid":"89069589-5750-41b7-a91e-18da7c03e0c3","product_id":2}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.OrderSerializer = DS.RESTSerializer.extend | |
primaryKey: "uuid" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Product = DS.Model.extend | |
name: DS.attr("string") | |
orders: DS.hasMany("order", async: true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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