title: Fetching an async hasMany relationship in the model hook
body: <p>Lets say I have two models, <code>Book</code> and <code>Chapter</code>.</p>
  
  <pre><code>App.Book = DS.Model.extend({
    name: DS.attr(),
    chapters: DS.hasMany('chapter', { async: true })
  });
  
  App.Chapter = DS.Model.extend({
    name: DS.attr(),
    book: DS.belongsTo('book')
  });
  </code></pre>
  
  <p>I'm using the <code>RESTAdapter</code>.</p>
  
  <pre><code>App.ApplicationAdapter = DS.RESTAdapter;
  </code></pre>
  
  <p>In the <code>IndexRoute</code> let's say I want to fetch the first book (id = 1) and it's associated chapters. Since the <code>hasMany</code> relationship is marked as <code>async: true</code>, I want to fetch this association before the template is rendered.</p>
  
  <pre><code>App.IndexRoute = Ember.Route.extend({
    model: function() {
      return Ember.RSVP.hash({
        book: this.store.find('book', 1)
      }).then(function(hash) {
        hash.chapters = hash.book.get('chapters');
        return hash;
      })
    },
    setupController: function(controller, model) {
      controller.set('model', model.book);
    }
  });
  </code></pre>
  
  <p>My index template simply displays the book title, and iterates over its chapters.</p>
  
  <pre><code>&lt;script type="text/x-handlebars" id="index"&gt;
    &lt;h3&gt;Book: {{name}}&lt;/h3&gt;
  
    &lt;ul&gt;
      {{#each chapters}}
        &lt;li&gt;{{name}}&lt;/li&gt;
      {{/each}}
    &lt;/ul&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>When using mockjax, I setup the mock responses.</p>
  
  <pre><code>$.mockjax({
    url: '/books/1',
    responseText: {
      book: {
        id: 1,
        name: 'Book 1',
        chapters: [1, 2]
      }
    }
  });
  
  $.mockjax({
    url: '/chapters?ids[]=1&amp;ids[]=2',
    responseText: {
      chapters: [{
        id: 1,
        name: 'Chapter 1',
        book_id: 1
      }, {
        id: 2,
        name: 'Chapter 2',
        book_id: 1
      }]
    }
  });
  </code></pre>
  
  <p>Problem 1: <a href="http://emberjs.com/guides/models/the-rest-adapter/#toc_relationships" rel="nofollow">According to the RESTAdapter docs</a>, accessing <code>book.get('chapters')</code> should issue a GET request to <code>/chapters?ids[]=1&amp;ids[]=2</code>. <strong>However, my console is showing two separate requests to <code>/chapters/1</code> and <code>/chapters/2</code>.</strong></p>
  
  <p>Problem 2: Furthermore, I believe the template is rendered <em>before</em> the chapters requests are happening because the template is rendered a second or two before I see the two requests to <code>/chapters/1</code> and <code>/chapters/2</code>. If I remove the call to <code>hash.book.get('chapters')</code> from the route, the same problem happens. <strong>In other words, I don't think the route is sending the request, I think the template is</strong>.</p>
  
  <p><a href="http://emberjs.jsbin.com/juxeximu/1/edit" rel="nofollow">Here is a jsbin</a>. You'll notice it doesn't show any chapters because I haven't setup the two routes it's requesting (<code>/chapters/1</code> and <code>/chapters/2</code>).</p>