Experimenting with ember-data models in console


Like most people, I think, I like to experiment with code in console.

When getting an ember-data model instance to experiment with, my general approach is:

// Usually I'm lazy and do `s = ...`
store = App.__container__.lookup('store:main')

// Again, lazy with `a = `, but that'll bite me later
accounts = store.find('account')

// Wait till the request completes, then
account = accounts.get('firstObject')

// Now I finally have an account to experiment with

While this isn’t terrible, I can’t help wonder if there’s an easier way. Am I missing something? Or am I just spoiled by the rails console (which would just be Account.first).


You can send entities like models and controllers to console from the Ember Inspector, right? Personally I always end up doing console.log(this) or something to see it.


Yes, you can click on the $E in the ember inspector for models that have loaded (click on $E in inspector and then type $E in console).

However, at the point when I need to experiment like this, I don’t usually have the models loaded. I suppose that could be a different approach though…


UPDATE: I’ve found ember-debug to be useful for this kind of console debugging.