Tagging in rails with is_taggable
there is an example provided on how to add tags to a model with is_taggable, and it works very nice (working in 5 minutes)
Now, I also need the opposite, show all reco开发者_如何学Pythonrds that are tagged with a certain word.
Something like:
ModelWithTag.find_by_tags "foo"
or
find_all_tagged_with "foo"
Is this possible with is_taggable ?
Yes, you could do the following:
Tag.where(:name => 'english').first.taggings
which would get you the list of all items tagged with 'english'
Cheers,
精彩评论