title: Getting rails3-jquery-autocomplete to show the number of instances of posts with a certain tag?
body: <p>I have a <em>Post</em> and <em>Tag</em> model with a many-to-many association:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    attr_accessible :title, :content
  
    has_many :taggings, :dependent =&gt; :destroy
    has_many :tags, :through =&gt; :taggings
  end
  
  class Tag &lt; ActiveRecord::Base
    has_many :taggings, :dependent =&gt; :destroy  
    has_many :posts, :through =&gt; :taggings
    has_many :subscriptions
    has_many :subscribed_users, :source =&gt; :user, :through =&gt; :subscriptions
  end
  
  class Tagging &lt; ActiveRecord::Base
    belongs_to :post  
    belongs_to :tag
  end
  </code></pre>
  
  <p>I'm using rails3-jquery-autocomplete:</p>
  
  <p><strong>posts_controller.rb:</strong></p>
  
  <p>autocomplete :tag, :name</p>
  
  <p><strong>routes.rb:</strong></p>
  
  <pre><code>  resources :posts do
      get :autocomplete_tag_name, :on =&gt; :collection
    end
  </code></pre>
  
  <p><strong>_form.html.erb:</strong></p>
  
  <pre><code>  &lt;div class="field"&gt;
      &lt;%= f.label :tag_names %&gt;&lt;br /&gt;  
      &lt;%= f.autocomplete_field :tag_names, autocomplete_tag_name_posts_path, :"data-delimiter" =&gt; ' ' %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>I works fine but I would like the auto-complete drop-down to show the number of posts with a certain tag. Like this:</p>
  
  <pre><code>---------------------
  | dr                |
  ---------------------
  |drinks (23)        |
  |drugs (4)       |
  |                   |
  ---------------------
  </code></pre>
  
  <p>(Pretty much like StackOverflow)</p>
  
  <p>I would appreciate any insight or example code.</p>