Ember from the console


#1

The ember guides points do this code:

var post = App.Post.find(1);

http://emberjs.com/guides/models/finding-models/

Which worked before ember data 1.0b

How do I make this now?

Tks!


#2

See the post about migrating to ED 1.0 beta. The new syntax is like so (in the model hook):

this.store.find('author', params.author_id);

#3

No, this doesn’t work from the chrome console.

With previous versions, App.Post.find(1) worked, now it gives me an error.


#4

Maybe you can do something like:

window.store = App.__container__.lookup('store:main');
window.store.find('post', id);

Just for debugging in the console, but I recommend getting the Ember Inspector, that helps with debugging the data as well.


#5

Yep, it works, thank you.

I’m not sure this is better than the old way, but works.


#6

its better from a “don’t leak globals” sense, likely a loss in ergonomics. I suspect we will see some improvements here shortly.


#7

Perhaps we could put this sort of thing into a special App.injectDebugHelpers method just like the App.injectTestHelpers() method.

I could imagine something like;

> App.injectDebugHelpers()
> debug.store
> debug.routes

#8

I too have run into difficulties accessing instances of important application objects in the debug console, so I created a short set of helpers that makes it easy:


#9

@slindberg would you care to share those helpers? :smiley:


#10

@commadelimited apparently gist embedding isn’t working anymore. Hopefully this will work: http://git.io/dJGyvw


#11

That’s fantastic! Thanks for sharing. Useful indeed!