title: Using jquery tokeninput and acts_as_taggable_on
body: <p>I've implemented the framework outlined in this post: <a href="https://stackoverflow.com/questions/6674127/how-to-use-jquery-tokeninput-and-acts-as-taggable-on">How to use jquery-Tokeninput and Acts-as-taggable-on</a> with some difficulty. This is working insofar as prepopulating with the appropriate theme and ajax search, but when I enter a new tag, it is immediately deleted when the text area loses focus. I'm not sure what I'm doing wrong. Here's some of my relevant code: </p>
  
  <p>User Model (does the tagging):</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  [...]
  # tagging
  acts_as_tagger
  </code></pre>
  
  <p>Item Model (accepts a tag):</p>
  
  <pre><code>class Item &lt; ActiveRecord::Base
  attr_accessible :title, :tag_list
  
  #tagging functionality
  acts_as_taggable_on :tags
  </code></pre>
  
  <p>Item Controller:</p>
  
  <pre><code>def tags 
  @tags = ActsAsTaggableOn::Tag.where("tags.name LIKE ?", "%#{params[:q]}%") 
   respond_to do |format|
    format.json { render :json =&gt; @tags.collect{|t| {:id =&gt; t.name, :name =&gt; t.name }}}
   end
  end
  </code></pre>
  
  <p>On my form partial:</p>
  
  <pre><code>&lt;%= f.input :tag_list, :label =&gt; "Tags", :input_html =&gt; { :class =&gt; "text_field short", "data-pre" =&gt; @item.tags.map(&amp;:attributes).to_json }, :hint  =&gt; "separate tags by a space"  %&gt;
  </code></pre>
  
  <p>my routes:</p>
  
  <pre><code>get "items/tags" =&gt; "items#tags", :as =&gt; :tags
  resources :items 
  </code></pre>
  
  <p>[almost there!!!]</p>
  
  <p>the js on the form [note: the id of the element is assigned dynamically]:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function() {
    $("#item_tag_list").tokenInput("/art_items/tags", {
      prePopulate:       $("#item_tag_list").data("pre"),
      preventDuplicates: true,
      crossDomain: false,
      theme: "facebook"
    });
  });
  &lt;/script&gt;
  </code></pre>