title: Associating custom Adapters with specific models in Ember CLI
body: <p>We recently made the switch from Ember to Ember CLI and I'm not able to find the proper convention for associating a model with a custom adapter.</p>
  
  <p><strong>History</strong>
  We created an adapter for models that have a file upload as part of their Create route so that form data and binary data could be pushed to one endpoint in our backend api [rails].  The adapter uses the FormData object for adding the file to the request.  I opted to only use this adapter for models with files and have non-file upload models use the application adapter.  So I would like the ember app to support multiple adapters.   </p>
  
  <p><strong>Custom Adapter:</strong>
  in adapters/file-upload.js</p>
  
  <pre><code>import DS from 'ember-data';
  
  var FileUploadAdapter = DS.ActiveModelAdapter.extend({
      ajaxOptions: function(url, type, hash) {
          var self = this;
          hash = hash || {};
          hash.url = url;
          hash.type = type;
          hash.dataType = 'json';
          hash.context = this;
  
          //add post data to formdata object
          if (hash.data &amp;&amp; type != 'GET' &amp;&amp; type !='DELETE') {
            hash.processData = false;
            hash.contentType = false;
            var fd = new FormData();
            var root = Object.keys(hash.data)[0];
  
            for (var i = 0; i &lt; Object.keys(hash.data[root]).length; i++) {
              var key = Object.keys(hash.data[root])[i];
              if (hash.data[root][key]) {
                fd.append(root + "[" + key + "]", hash.data[root][key]);
              }
            }
            hash.data = fd;
          }
  
          var headers = this.get('headers');
          if (headers) {
            hash.beforeSend = function(xhr){
              for (var i = 0; i &lt; Ember.keys(headers).length; i++) {
                xhr.setRequestHeader(Ember.keys(headers)[i], headers[Ember.keys(headers)[i]]);
              }
            }
          }
  
          return hash;
      }
  });
  
  export default FileUploadAdapter;
  </code></pre>
  
  <p>In "classic" Ember, I was able to tell ember to use a specific adapter on a model through this convention:</p>
  
  <pre><code>//given a model name "Person", specific adapter via {ModelName}Adapter
  App.PersonAdapter = App.FileUploadAdapter.extend();
  </code></pre>
  
  <p>But now that we don't have these global objects in Ember CLI, is there a way to specify an adapter?  I assume that I will want to assign my model to a variable before exporting it and doing additional settings work there.</p>
  
  <p>I desire to fit within the ember cli paradigm, so please let me know if you think this is moving too far away from it.  I could go back to using one adapter and doing file detection within it, but separating custom functionality into multiple adapters feels cleaner.</p>
  
  <p>Thanks!</p>