title: data-pre rails 3 + jquery tokeninput + acts_as_taggable_on
body: <p>i am developing an application that works with tags, to do so, i am using jquery tokeninput and acts_as_taggable_on, but when save some changes, the tags start to show there id number instead of name also when save again the existing tags again with the number as the name.</p>
  
  <p>i think that is a data-pre error or a mapping error.</p>
  
  <p>in my view:
  </p>
  
  <pre><code>= form_for @profile, :html=&gt; {:class =&gt; 'custom'} do |f|
  = f.text_field :skill_list, :id =&gt; "profile_skills", "data-pre" =&gt; @profile.skills.to_json
  </code></pre>
  
  <p>controller:
  </p>
  
  <pre><code>def skills
  query = params[:q]
  if query[-1,1] == " "
    query = query.gsub(" ", "")
    ActsAsTaggableOn::Tag.find_or_create_by_name(query)
  end
  
  @skills = ActsAsTaggableOn::Tag.all
  @skills = @skills.select { |v| v.name =~ /#{query}/i }
  respond_to do |format|
    format.json { render :json =&gt; @skills.map{|t| {:id =&gt; t.name, :name =&gt; t.name }}}
  end
  </code></pre>
  
  <p>end</p>
  
  <p>application.js:
  </p>
  
  <pre><code>$(function(){ 
  $(document).foundation(); 
  $("#profile_skills").tokenInput("/profiles/skills.json", {
      prePopulate:       $("#profile#skills").data("pre"),
      preventDuplicates: true,
      hintText:          "Ingresa alguna habilidad",
      noResultsText:     "No se encontraron tags, crea uno con espacio",
      searchingText:     "Buscando...",
      animateDropdown:   true,
      theme: 'facebook'
  </code></pre>
  
  <p>});
  });</p>
  
  <p>routes:
  </p>
  
  <pre><code>get "profiles/skills" =&gt; "profiles#skills", :as =&gt; :profiles_skills
  </code></pre>