Skip to content

Instantly share code, notes, and snippets.

@rubish
Forked from joemsak/_footer.html.erb
Created July 18, 2011 17:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubish/1090097 to your computer and use it in GitHub Desktop.
Save rubish/1090097 to your computer and use it in GitHub Desktop.
Using jQuery TokenInput with ActsAsTaggableOn
<div class='field'>
<%= f.label :tag_list, "Tags" %>
<%= f.text_field :tag_list, :class => 'larger widest', :"data-pre" => @model.tags.map(&:attributes).to_json %>
</div>
#example_get_all_tags_path needs to route here. (name it something else obviously)
def tags
@tags = Model.tag_counts.where("tags.name LIKE ?", "%#{params[:q]}%")
respond_to do |format|
format.json { render :json => @tags.map(&:attributes) }
end
end
# some routes
# add following route, just before `resources :products`
get "products/tags" => "products#tags", :as => :products_tags
resources :products
# some more routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment