Created
June 9, 2013 20:31
-
-
Save alnutile/5745091 to your computer and use it in GitHub Desktop.
Acts As Taggable making a list of a tag using context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#app/views/shared/_states.html.erb | |
<% states_list.each do |state| %> | |
<li> | |
<%= link_to state.name, {:state => state.name} %> | |
</li> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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