Search code examples
ruby-on-rails-3acts-as-taggable-on

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 ?


Solution

  • 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