ruby on rails - Find tag by id using acts_as_taggable_on -
I am working on Ruby 2.3.8 and using the works_as_taggable_on plugin. This plugin generates three tables: tags (which have the ID and name of each tag) and tagging (related to tag_ids that are tagged items).
Now, I want to get all the tagged items with a definitive tag_id, so I go to my announcement model (announcements are tagged items) and I would like to write something like this:
def find_by_category (tag_id) announcement. Tagged_with (tag_id) #this does not exist Finally
But in fact I found that the only way was:
announcement. Tagged_with (tag_NAME) #this works, but I do not want to search by a name
Does anyone know a method to accomplish this, or at least, this How to modify the code of the plugin?
tag = ActsAsTaggableOn :: Tag.find (tag_id) declaration. Tweaked_with (tag)
After one year, I hope this is useful for anyone!
Comments
Post a Comment