Debugging Ember.js and Ember Data
Feb 22 2013

Debugging EmberJS and Ember Data:

Things I found useful while debugging problems. They are current as of Ember.js 1.0.0.rc1.

  • Log router transitions:
1
2
3
  window.App = Ember.Application.create({
    LOG_TRANSITIONS: true,
  });
  • Log object bindings:
  Ember.LOG_BINDINGS = true
  • View all registered routes:
  Ember.keys(App.Router.router.recognizer.names)
  • View all registered templates:
  Ember.keys(Ember.TEMPLATES)
  • Get the state history of an ember-data record:
  record.stateManager.get('currentPath')
  • Get the View object for a generated ember div by its div id.
  Ember.View.views['ember605']
  • Log state transitions:
  record.set("stateManager.enableLogging", true)
  • View an instance of something from the container:
1
2
  App.__container__.lookup("controller:posts")
  App.__container__.lookup("route:application")
  • View ember-data's identity map:
1
2
3
  App.__container__.lookup('store:main').recordCache # all records in memory
  App.__container__.lookup('store:main').recordCache[2].get('data.attributes') #attributes
  App.__container__.lookup('store:main').recordCache[2].get('comments') #loaded associations
  • See all observers for a object, key:
  Ember.observersFor(comments, keyName);
  • Dealing with deprecations:
1
2
Ember.ENV.RAISE_ON_DEPRECATION = true
Ember.LOG_STACKTRACE_ON_DEPRECATION = true
  • Handlebars:
1
2
  {{debugger}}
  {{log record}}
  • Implement a Ember.onerror hook to log all errors in production:
1
2
3
4
5
6
  Ember.onerror = function(error) {
    Em.$.ajax('/error-notification', 'POST', {
      stack: error.stack,
      otherInformation: 'exception message'
    });
  }
  • Use ember extension when its ready:

    https://github.com/tildeio/ember-extension.git
comments powered by Disqus