why
why

Reputation: 24851

Is there a good methods to find user's all tags with acts-as-taggable-on?

I use acts-as-taggable-on https://github.com/mbleigh/acts-as-taggable-on for tagging user's post, I want to find one user's all post' all tags and list them, Is there a high performance method ?

Upvotes: 1

Views: 121

Answers (1)

Matenia Rossides
Matenia Rossides

Reputation: 1414

You need to add acts_as_tagger to the User model

refer to https://github.com/mbleigh/acts-as-taggable-on#tag-ownership

then you can use the methods provided. If you're starting from a blank db, this should work but may need to run through some re-assigning loop to have the tagger association work.

Assuming your data is correct, you will then be able to do:

@some_user.owned_taggings
@some_user.owned_tags

Hope this helps

Upvotes: 3

Related Questions