Search code examples
ruby-on-railsacts-as-taggable-on

Get all tags on taggable object - no matter context


I use acts-as-taggable-on on a collection of photos. I have a general :tags context and an :objectives context that users use for stuff that is in the photo. In the UI I add both tag contexts into the same box. It would be nice if I could get all tags and objectives on one photo in one command, like:

photo.gimme_all_tags_no_matter_context #would give me combined list of general tags and objectives.

Currently I do this:

tags = "#{photo.tags.map{|c| c.name}.join(",")},#{photo.objectives.map{|c| c.name}.join(",")}"

Is there a way to do that?


Solution

  • You table with all tags is

    ActsAsTaggableOn::Tagging
    

    To get all tags you do this

    ActsAsTaggableOn::Tag.all