title: Jquery token input autocomplete not working on facebook friends array with rails 3
body: <p>I'm working on a text field with autocomplete from your facebook friends using this tutorial:
  <a href="http://railscasts.com/episodes/258-token-fields?autoplay=true" rel="nofollow">http://railscasts.com/episodes/258-token-fields?autoplay=true</a></p>
  
  <p>i get in the js console this error:</p>
  
  <p>Uncaught TypeError: Cannot call method 'replace' of undefined
  highlight_termjquery.tokeninput.js:609
  $.TokenList.selected_dropdown_itemjquery.tokeninput.js:628
  jQuery.extend.eachjquery.js:641
  populate_dropdownjquery.tokeninput.js:627
  run_searchjquery.tokeninput.js:704
  $.TokenList.ajax_params</p>
  
  <p>my code is:</p>
  
  <p>JS:</p>
  
  <pre><code>$(function() {
    $("#when").datetimepicker();
    $("#who").tokenInput("/memberships.json", {
      crossDomain: false,
      theme: "facebook"
    });
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;% form_for @doweet, :html =&gt; { :id =&gt; "post" } do |f| %&gt;
  
  &lt;%= error_messages_for @doweet %&gt;
  
  &lt;%= f.text_field :doweet_member_tokens,  :id =&gt; "who", :placeholder =&gt; "Who?" %&gt;  
  
  &lt;%= f.submit "Doweet" %&gt;
  </code></pre>
  
  <p>rails:</p>
  
  <p>memberships.json:</p>
  
  <pre><code>q = params[:q]
  @friend_members = FbGraph::Query.new("SELECT name,uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name asc").fetch(current_user.token).collect { |f| f["name"] }.select { |v| v =~ /#{Regexp.escape(q)}/i  } 
  respond_to do |format|
    format.html
    format.json { render :json =&gt; @friend_members }
  end
  </code></pre>
  
  <p>i'm getting back from this an array like this: ["Shlomi Caduri","Shlomit Harth"]</p>
  
  <p>doweet.rb:</p>
  
  <pre><code>  attr_reader :doweet_member_tokens
  
    def doweet_member_tokens=(ids)
      self.doweet_member_ids = ids.split(",")
    end
  </code></pre>
  
  <p>the js and css files are attached properly.</p>
  
  <p>the problem is that when i search a name i don't see a results and if i go manuly to localhost:3000/memberships.json?q=asdf i see... i think the problem is in the JS...</p>
  
  <p>what i do wrong?</p>
  
  <p>thanks a lot,</p>
  
  <p>gal</p>