acts as taggable on steroids - seach all tags

Hi,

When using acts as taggable on steroids, you can search a model's tags But how do you search all tags without using manual sql and not limit it just to one model?   

When you install the plugin you have the taggings table and the corresponding Tagging model. Tagging is related to the model Tag.

So, you could do something like

Tagging.find(:all,:include=>:tag,:conditions=>['tags.name in (?)',tags_to_search])

That will give you all the taggings, having the model name in the "taggable_type" attribute and the id in the taggable_id field.

Moreover, Tagging has a polymorphic reference to :taggable, meaning you could directly get the related objet directly by invoking .taggable over any of the row results. Just be aware you'll be launching a new query for each row if you do so since as far as I know you cannot eager load a polymorphic association.

Regards,

javier ramírez