title: How to get the return data of a save with Ember Data?
body: <p>I'm using Ember.js with ember-data to make a GUI for a self made API.</p>
  
  <p>I've been following this <a href="http://coderberry.me/blog/2013/07/08/authentication-with-emberjs-part-2/" rel="nofollow">tutorial</a> to handle authentication but I want to use ember-data instead of custom jQuery requests.</p>
  
  <p>One thing I have to do is to call the API to create a new session, by sending email and password, and the API sends me back an API Key object.</p>
  
  <p>Here is my LoginController handling the loginUser action (it's CoffeeScript) :</p>
  
  <pre><code>App.LoginController = Ember.ObjectController.extend
    actions:
      loginUser: -&gt;
        session = @store.createRecord 'session',
          email:    @get 'email'
          password: @get 'password'
        session.save()
  </code></pre>
  
  <p>Here is the result I get when creating a session: </p>
  
  <pre><code>{
      "users": [
          {
              "id": "525fa0286c696c0b14040000",
              "email": "john.doe@mydomain.com",
              "first_name": "John",
              "surname": "Doe"
          }
      ],
      "api_key": {
          "id": "526e464c6c696c07d2000000",
          "type": "session",
          "key": "6b824d6a-a065-4b6f-bb28-5c19389760f8",
          "expires_at": "2013-10-28T11:41:08+00:00",
          "user_id": "525fa0286c696c0b14040000"
      }
  }
  </code></pre>
  
  <p>I have Session, ApiKey and User models. I can create the session, but the thing I don't understand is how to access the return value of the <code>save()</code> method.</p>
  
  <p>I know that my ApiKey and User are loaded somewhere because I get an error after <code>save()</code> if their respective Ember model don't exist but I don't know how to access them.</p>
  
  <p>I've tried to use <code>save()</code> callbacks like <code>then()</code> or <code>didCreate</code> event but there's a lack of documentation about arguments passed to these callbacks and how to use them.</p>
  
  <ul>
  <li>Ember.js <strong>1.1.2</strong></li>
  <li>Ember Data <strong>1.0.0.beta.3</strong></li>
  </ul>
  
  <p><strong>EDIT:</strong>
  I've tried to create an actuel Session model on my API, resulting in this JSON output:</p>
  
  <pre><code>{
      "api_keys": [
          {
              "id": "526f69526c696c07d2110000",
              "type": "session",
              "key": "4c26af37-2b21-49c2-aef5-5850a396da0b",
              "expires_at": "2013-10-29T08:22:50+00:00",
              "user_id": "525fa0286c696c0b14040000"
          }
      ],
      "users": [
          {
              "id": "525fa0286c696c0b14040000",
              "email": "john.doe@coreye.fr",
              "first_name": "John",
              "surname": "Doe"
          }
      ],
      "session": {
          "id": "526f6e666c696c18c0010000",
          "api_key_id": "526f69526c696c07d2110000"
      }
  }
  </code></pre>
  
  <p>(note the root element is now <code>session</code>)</p>
  
  <p>It doesn't work better because now my save action leads to the following error (not in the console but <code>then</code> points to error callback):</p>
  
  <pre><code>Object function () { [...] } has no method 'eachTransformedAttribute'
  </code></pre>
  
  <p>I get this error, the relation between Session and ApiKey being declared in Ember Data models or not...</p>