Ember from the console

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!

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);

No, this doesnā€™t work from the chrome console.

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

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.

2 Likes

Yep, it works, thank you.

Iā€™m not sure this is better than the old way, but works.

its better from a ā€œdonā€™t leak globalsā€ sense, likely a loss in ergonomics. I suspect we will see some improvements here shortly.

1 Like

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
4 Likes

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:

https://gist.github.com/slindberg/7490896

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

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

Thatā€™s fantastic! Thanks for sharing. Useful indeed!