Call store from within a controller


Hello everyone,

ember newby here. I need to get back some metadata from the server after a PUT request, therefor I want to use the native ember function ‘store.metadataFor()’ within the controller after saving. My code looks like this (coffeescript):

I want to get the value of the key ‘message’ from the metadata. The json form the server is ok (keyname ‘meta’)…however I get the error:

Error: Assertion Failed: TypeError: is undefined

I’m able to access the store from withing routes, but as far I understand the concept it should work from withing a controller too…

Any help would be appreciated, Thank you


I’m not fluent in coffeescript, so this could be off the mark, but if that @store is equivalent to, then you have the problem that ‘this’ is scoped to the global context rather than your controller (if you want I could elaborate on this, but it’s a pretty common javascript quirk). I have written the exact lines of code you have there many times, and always end up with something like

save: function () {
    var that = this;
    this.get('content').save(function () {


You are awesome! Saved me, thank you for your quick reply!