开发者

Tagging in rails with is_taggable

开发者 https://www.devze.com 2022-12-25 01:15 出处:网络
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)

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,

0

精彩评论

暂无评论...
验证码 换一张
取 消