Skip to content

Instantly share code, notes, and snippets.

@alnutile
Created June 9, 2013 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alnutile/5745091 to your computer and use it in GitHub Desktop.
Save alnutile/5745091 to your computer and use it in GitHub Desktop.
Acts As Taggable making a list of a tag using context
#app/views/shared/_states.html.erb
<% states_list.each do |state| %>
<li>
<%= link_to state.name, {:state => state.name} %>
</li>
<% end %>
module ApplicationHelper
include ActsAsTaggableOn::TagsHelper
def states_list
ActsAsTaggableOn::Tag.includes(:taggings).where("taggings.context = 'state'")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment