title: Packaging an object for a model with a dynamic route is undefined — why?
body: <p>Playing around with with EmberJS, and I'm trying to understand some behaviour with routes right now. </p>
  
  <p>I'm building a test app with the intention of hooking into the Rdio API and displaying albums/songs for various artists. </p>
  
  <p><a href="http://jsbin.com/puqokupura/1/" rel="nofollow noreferrer">Here's a JsBin.</a> </p>
  
  <p>Right now, there are only two views: The <strong>Index</strong> (a listing of all available albums), and an individual <strong>Album</strong> view. </p>
  
  <p>The dynamic route is defined like so: </p>
  
  <pre><code>App.Router.map(function() {
    this.route("album", { path: "/album/:key" });
  });
  </code></pre>
  
  <p>And given a fixture that looks like this...</p>
  
  <pre><code>App.ALBUMS = {
   "status": "ok", 
   "result": [
    {
     "key": "a5337866", 
     "icon": "http://rdio3img-a.akamaihd.net/album/a/0/3/000000000051730a/3/square-200.jpg", 
     "artist": "The Decemberists", 
    }, 
    {
     "key": "a5229271", 
     "icon": "http://rdio1img-a.akamaihd.net/album/7/d/a/00000000004fcad7/1/square-200.jpg", 
     "artist": "Nicki Minaj", 
    }, 
    ]
  };
  </code></pre>
  
  <p>...the index works just fine: </p>
  
  <pre><code>App.IndexRoute = Ember.Route.extend({
    model: function() {
      return {albums:App.ALBUMS.result }
    }
  });
  </code></pre>
  
  <p>(I've intentionally packaged <em>App.ALBUMS.result</em> in an object so that I can pack more information into it later.)</p>
  
  <p><img src="https://i.stack.imgur.com/MuHxX.png" alt="Lyrically Index Page"></p>
  
  <p>However, when I get to the Album view, I get a problem: </p>
  
  <pre><code>App.AlbumRoute = Ember.Route.extend({
    model: function(params){
      console.log(params);
      console.log(App.ALBUMS.result.findBy('key',params.key)); //Logs object just fine
      return App.ALBUMS.result.findBy('key',params.key); //ERROR
    }
  });
  </code></pre>
  
  <p>Packaging that return value (which should already be an object) in a second object or array though, and it works. </p>
  
  <pre><code>// THIS WORKS!: 
  return [App.ALBUMS.result.findBy('key',params.key)]; 
  // THIS AlSO WORKS!:
  return {album: App.ALBUMS.result.findBy('key',params.key)}; 
  </code></pre>
  
  <p><strong>Why?</strong> </p>
  
  <p><strong>App.ALBUMS.result.findBy('key',params.key)</strong> alone should be (and is) returning an object, so why does Ember choke on it? </p>
  
  <p>The error itself is rather unhelpful:</p>
  
  <pre><code>     Error while processing route: album undefined is not a function TypeError: undefined is not a function
      at EmberObject.extend._setupArrangedContent (http://local.lyrically.com/js/libs/ember-1.9.1.js:34181:27)
      at null._arrangedContentDidChange (http://local.lyrically.com/js/libs/ember-1.9.1.js:34167:14)
      at applyStr (http://local.lyrically.com/js/libs/ember-1.9.1.js:19677:29)
      at sendEvent (http://local.lyrically.com/js/libs/ember-1.9.1.js:14115:13)
      at notifyObservers (http://local.lyrically.com/js/libs/ember-1.9.1.js:17488:9)
      at propertyDidChange (http://local.lyrically.com/js/libs/ember-1.9.1.js:17291:7)
      at iterDeps (http://local.lyrically.com/js/libs/ember-1.9.1.js:17373:11)
      at dependentKeysDidChange (http://local.lyrically.com/js/libs/ember-1.9.1.js:17329:9)
      at propertyDidChange (http://local.lyrically.com/js/libs/ember-1.9.1.js:17287:9)
      at iterDeps (http://local.lyrically.com/js/libs/ember-1.9.1.js:17373:11)
  </code></pre>