gutentag
gutentag copied to clipboard
Ability to get tag objects for a scope
I can only find the class method
Gutentag::Tag.names_for_scope(Blog::Post)
which returns all the names of the tags for a scope (in my case Blog::Post)
But if I want to display a tag cloud with the number showing how many times the tags are used, I have to use
Blog::Post.tagged_with(names: <tag_name>).count
which is very uneffective.
On a Blog::Post instance I can ask for tag objects with Blog::Post.tags and it contains the field taggings_count. I would like to get something similar for all tags of Blog::Post.
Gutentag::Tag.all does not help either as it contains all tags, not just for my scope. (Not to mention that it is not documented either)
Currently, as a workaround, I can use this:
Gutentag::Tag.joins(:taggings).where(taggings:{taggable_type: 'Blog::Post'})