diff --git a/packages/ember-data/lib/system/debug/debug-adapter.js b/packages/ember-data/lib/system/debug/debug-adapter.js index fb81957483a..8c62dd97ffc 100644 --- a/packages/ember-data/lib/system/debug/debug-adapter.js +++ b/packages/ember-data/lib/system/debug/debug-adapter.js @@ -5,6 +5,7 @@ import Model from "ember-data/system/model"; var get = Ember.get; var capitalize = Ember.String.capitalize; var underscore = Ember.String.underscore; +const { assert } = Ember; /** Extend `Ember.DataAdapter` with ED specific code. @@ -42,11 +43,15 @@ export default Ember.DataAdapter.extend({ return columns; }, - getRecords: function(modelNameOrFactory) { - // TODO: Ask Teddy what we should do here. - // Ideally this should always get passed a string. - - var modelName = typeof modelNameOrFactory === 'string' ? modelNameOrFactory : modelNameOrFactory.modelName; + getRecords: function(klass, modelName) { + if (arguments.length < 2) { + // Legacy Ember.js < 1.13 support + let containerKey = klass._debugContainerKey; + if (containerKey) { + modelName = containerKey.match(/model:(.*)/)[1]; + } + } + assert("Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support", !!modelName); return this.get('store').all(modelName); }, diff --git a/packages/ember-data/tests/integration/debug-adapter-test.js b/packages/ember-data/tests/integration/debug-adapter-test.js index 1bada903bd8..90b309e0d04 100644 --- a/packages/ember-data/tests/integration/debug-adapter-test.js +++ b/packages/ember-data/tests/integration/debug-adapter-test.js @@ -15,8 +15,10 @@ module("DS.DebugAdapter", { App.Post = DS.Model.extend({ title: DS.attr('string') }); + + // TODO: Remove this when Ember is upgraded to >= 1.13 App.Post.reopenClass({ - modelName: 'post' + _debugContainerKey: 'model:post' }); });