title: Select2 returns TypeError: data is undefined
body: <p>I'm trying to get Select2 working with Rails. I have the API endpoint working but I get a <code>TypeError: data is undefined</code> message in my console, so the select fields aren't being populated.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>$(document).ready(function() {
    return $('#form_emails').select2({
      placeholder: 'User list',
      minimumInputLength: 3,
      ajax: {
        url: '/api/s/users',
        dataType: 'json',
        quietMillis: 250,
        data: function(term) {
          return { q: term };
        },
        results: function(data) {
          var results;
          results = [];
          $.each(data, function(idx, item) {
            results.push({
              'id': item.id,
              'text': item.first_name + ' ' + item.last_name
            });
          });
          return { results: results };
        }
      }
    });
  });
  </code></pre>
  
  <p>Any idea why I might be getting the aforementioned error? Thanks in advance!</p>