First things first.
This is NOT a duplicate of Get all tags on taggable object - no matter context. I am looking for all tags on a specific model object. Not for all possible tags in my entire rails app.
This is NOT a duplicate of Listing all tags for an acts_as_taggable. I am looking for all tag on an object on all contexts - not on just a single context.
I have a my_car
instance of a Car
class. I have many taggings on it on wheel
context, on body
context, on interior
context, and some general tags on tags
context.
While i am able to my_car.tags_list
, my_car.wheel_list
, my_car.body_list
, my_car.interior_list
, i am not able to do something like my_car.all_tags
so that i can see ALL the tags on the my_car
object regardless of their tagging contexts.
How do i do that?
c.base_tags.map(&:name)
There is no built-in shortcut to get the names directly, but that's short enough :)
Edit: base_tags
is an association defined on classes declared as taggable: has_many :base_tags, through: :taggings, source: :tag, class_name: '::ActsAsTaggableOn::Tag'
Source: https://github.com/mbleigh/acts-as-taggable-on/blob/master/lib/acts_as_taggable_on/taggable.rb