title: Single route with dynamic segments coming from two different models
body: <p>I have a Project model that belongsTo an Account model. Both of these models have permalinks used to generate pretty URLs. The Project permalinks are unique when scoped to their parent Account, so I need both permalinks to resolve the actual Project.</p>
  
  <p>I am having trouble implementing a route serialize method to fill in the dynamic segments using both models.</p>
  
  <p>Here's the route with dynamic segments:</p>
  
  <pre><code>this.route('tasks', {path: 'p/:account_permalink/:project_permalink/board'});
  </code></pre>
  
  <p>The tasks route has this serialize method:</p>
  
  <pre><code>serialize: function(project) {
    return {
      account_permalink: project.get("account.permalink"), 
      project_permalink: project.get("permalink")
    };
  }
  </code></pre>
  
  <p>When I use this in a link-to, the account_permalink segment comes back as undefined:</p>
  
  <pre><code>{{#link-to "tasks" project}}
    {{project.account.name}}: {{project.name}}
  {{/link-to}}
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>&lt;a id="ember688" href="/p/undefined/first-project/board" class="ember-view"&gt;
    KappenCo: First Project
  &lt;/a&gt;
  </code></pre>
  
  <p>The interesting thing is that if I use account.id instead of account.permalink, the dynamic segment is filled in with the id:</p>
  
  <pre><code>serialize: function(project) {
    return {
      account_permalink: project.get("account.id"), 
      project_permalink: project.get("permalink")
    };
  }
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>&lt;a id="ember619" href="/p/1/first-project/board" class="ember-view"&gt;
    KappenCo: First Project
  &lt;/a&gt;
  </code></pre>
  
  <p>This smelled like an async loading issue, so I tried using promises to load the account first:</p>
  
  <pre><code>serialize: function(project) {
    project.get("account").then((a) =&gt; {
      return {
        account_permalink: a.get("permalink"), 
        project_permalink: project.get("permalink")
      };
    });
  }
  </code></pre>
  
  <p>But it results in an error, a is always null:</p>
  
  <pre><code>TypeError: Cannot read property 'get' of null
  </code></pre>
  
  <p>There are lots of examples of filling multiple dynamic segments from the same model, but nothing that requires two different models to collaborate in filling the segments. This has been so difficult that I must be using the framework incorrectly, how do I achieve this the ember way?</p>
  
  <p>The app is using Ember 1.13.7 and ember-data 1.13.9 in case that's a source of the problem.</p>