title: Twitter-Typeahead isn't offering suggestions
body: <p>I'm trying to use <code>twitter-typeahead-rails</code>. My intention is for instances of the model "User" to be suggested via a drop-down box as I type into the "#Typeahead" input box. However, nothing happens when I type.</p>
  
  <p>Does anyone see anything that could be wrong with my code?</p>
  
  <p><strong>Gemfile:</strong></p>
  
  <pre><code>gem 'twitter-typeahead-rails'
  </code></pre>
  
  <p><strong>layouts/application.js:</strong></p>
  
  <pre><code>//= require twitter/typeahead
  //= require twitter/typeahead/bloodhound
  </code></pre>
  
  <p><strong>config/routes.rb:</strong></p>
  
  <pre><code>get 'typeahead/:query' =&gt; 'users#typeahead'
  </code></pre>
  
  <p><strong>controllers/users_controller.rb:</strong></p>
  
  <pre><code>def typeahead
    render json: User.where(name: params[:query])
  end    
  </code></pre>
  
  <p><strong>views/users/show.html.erb:</strong></p>
  
  <pre><code>&lt;input type="text" id="typeahead"&gt;
  &lt;script type="text/javascript"&gt;
    var bloodhound = new Bloodhound({
      datumTokenizer: function (d) {
        return Bloodhound.tokenizers.whitespace(d.value);
      },
      queryTokenizer: Bloodhound.tokenizers.whitespace,
  
      remote: '/typeahead/%QUERY', 
      limit: 50
    });
    bloodhound.initialize();
  
    $('#typeahead').typeahead(null, {
      displayKey: 'name',
      source: bloodhound.ttAdapter()
    });
  
    $('#typeahead').bind('typeahead:selected', function(event, datum, name) {
      doSomething(datum.id);
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>I'm not getting any errors in the web console, and all the necessary files are apparently being included:</p>
  
  <p><strong>Page source</strong></p>
  
  <pre><code>&lt;script data-turbolinks-track="true" src="/assets/twitter/typeahead.bundle.js?body=1"&gt;&lt;/script&gt;
  &lt;script data-turbolinks-track="true" src="/assets/twitter/typeahead.js?body=1"&gt;&lt;/script&gt;
  &lt;script data-turbolinks-track="true" src="/assets/twitter/typeahead/bloodhound.js?body=1"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><strong>Network console:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/KAGGD.png" alt="Headers"></p>