Closed github0013 closed 5 years ago
You are correct, the taggings_count
is the entire count for that tag, not the count for any particular model's usage.
If you wanted to get a count for a particular class, you could try the following:
ActsAsTaggableOn::Tagging.where(taggable_type: "Post").group(:tag_id).select("count(tag_id) tag_count, tag_id").first.tag_count
Alternatively, you could use SQL to get the result you're looking for.
Please close this issue after reviewing this response.
Let's say I have User and Post models where
has_many
postsbelongs_to
usertags
tag_counts_on on model
tag_counts_on
on Post model gives me this, and I understand it.tag_counts_on on model instance
However, when I do
tag_counts_on
on Post model instance, the results are unexpectedthe
taggings_count
on both results are2
instead of1
that I expected.It seems it only filters tag names that exist in its instance, but not the
taggings_count
.taggings_count
is rather entire count instead of the number of counts that is saved for the instance.Is this how it's meant to be done?