title: How to support multiple API hosts with Ember data?
body: <p>I have an Ember application (with ember data) that is run on a user's machine. There's an API server running on their machine, and one running online. I need to allow users to choose where a model is persisted (the API running on their machine, or the online API). So, two API hosts:</p>
  
  <pre><code>http://localhost:3000
  and
  http://api.example.com
  </code></pre>
  
  <p>When a user creates a record, they can set wether they want the record saved locally (through the local API server), or saved online. I persist this choice to a value on the record called dataSource.</p>
  
  <p>So, depending on the record dataSource, I need to set the ember RestAdapter host for the model to the correct value. I understand one can override adapters on a per model basis. For example, I could create a RecordAdapter and manually set the host to a value. However, the host depends on a value in the record, and I'm not sure how to accomplish this with Ember Data, since the rest adapter "host" is a property, not a function.</p>
  
  <p><a href="http://emberjs.com/api/data/classes/DS.RESTAdapter.html#property_host" rel="nofollow">http://emberjs.com/api/data/classes/DS.RESTAdapter.html#property_host</a></p>
  
  <p>User flow example:</p>
  
  <ul>
  <li>User creates new record, chooses the option to store this record locally.</li>
  <li>Record is persisted to localhost.</li>
  <li>User creates a new record, chooses the option to store this record online.</li>
  <li>Record is persisted to <a href="http://api.example.com" rel="nofollow">http://api.example.com</a></li>
  <li>Any time a record is saved, updated, deleted, etc, it must check the record dataSource to determine the api host to use in the operation.</li>
  </ul>