Acts-as-taggable-on find all tags by context Acts-as-taggable-on find all tags by context sql sql

Acts-as-taggable-on find all tags by context


You could also use a statement like the following:

# Returns all the tags for the specified model/context with a count >= 1@tags = YourModel.tag_counts_on(**context**)

Add limit and order:

# Get the top 5 tags by count@tags = YourModel.tag_counts_on(**context**, :limit => 5, :order => "count desc")

Access the counts with the count attribute of the tags returned from tag_counts_on

tag.count


I believe there is the way:User.tag_counts_on(:tags)

=> [#<ActsAsTaggableOn::Tag id: 1, name: "foo">,#<ActsAsTaggableOn::Tag id: 2, name: "bar">,#<ActsAsTaggableOn::Tag id: 3, name: "sushi">,#<ActsAsTaggableOn::Tag id: 4, name: "pizza">]