title: Autofill using jquery and RoR error?
body: <p>Im trying to autofill a text filed using jquery plugin Autocomplete but im running in to a couple of problems, no list is genrated in the view and i get an error in firbug saying: </p>
  
  <pre><code>500 Internal Server Error, &lt;h1&gt;Template is missing&lt;/h1&gt;
  &lt;p&gt;Missing template messages/query with {:handlers=&amp;gt;[:erb, :builder, :rjs, :rhtml, :rxml], :locale=&amp;gt;[:en, :en], :formats=&amp;gt;[:json, :js, &amp;quot;*/*&amp;quot;]} in view paths &amp;quot;/Users/aldeirm2/Desktop/CMS2/app/views&amp;quot;&lt;/p&gt;. 
  </code></pre>
  
  <p>im guessing it has to do with the way im trying to return the json object?</p>
  
  <p>Here is javascript code: </p>
  
  <pre><code>$(function() {
      var cache = {},
          lastXhr;
      $( "#username" ).autocomplete({
          minLength: 1,
          source: function( request, response ) {
              var term = request.term;
              if ( term in cache ) {
                  response( cache[ term ] );
                  return;
              }
  
              lastXhr = $.getJSON( "/usernames", request, function( data, status, xhr ) {
                  cache[ term ] = data;
                  if ( xhr === lastXhr ) {
                      response( data );
                  }
              });
          }
      });
  });
  </code></pre>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;label for="username"&gt;To:&lt;/label&gt;  &lt;input id="username" /&gt;&lt;br /&gt;
  </code></pre>
  
  <p>search method in controller (routed to used "/search"): </p>
  
  <pre><code>  def query
      @users = User.auto_fill(params[:term])
  
      logger.debug "This is the USERS" + @users.first.username
      return @users.collect{|x| {:label =&gt; x.name, :id =&gt; x.id}}.to_json
    end
  </code></pre>
  
  <p>auto_fill method in model:</p>
  
  <pre><code>def self.auto_fill(search)
      query = "%#{search}%"
      where("username like ?", query)
    end
  </code></pre>
  
  <p>any help would be great thanks. </p>