GhostRider
GhostRider

Reputation: 2170

Rails 4, Acts as taggable: finding number of users with the same tag

I suspect this is straightforward. I have a user model and I am using the acts as taggable gem with this

  acts_as_taggable

  acts_as_taggable_on :tags

I want to find the number of users that have a specific tag.

I have tried

      User.tag_counts_on("pharmacology")

without success. Any help would be appreciated.

Upvotes: 0

Views: 85

Answers (1)

Milind
Milind

Reputation: 5112

if you have tag_list attribute..which stores the tags of the users..then you can try this:-

tag_list=['Good','Bad','Frequent']
User.tagged_with(tag_list,:any=>true) 

this will give you all the users with any of the tags mentioned. View this for more info from acts-as-taggable-on

Upvotes: 1

Related Questions