问题
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?
回答1:
You table with all tags is
ActsAsTaggableOn::Tagging
To get all tags you do this
ActsAsTaggableOn::Tag.all
来源:https://stackoverflow.com/questions/37689149/get-all-tags-on-taggable-object-no-matter-context