开发者

acts_as_taggable_on: query for users tagged with any of these tags

开发者 https://www.devze.com 2023-01-07 18:46 出处:网络
I\'m using acts_as_taggable_on and I\'m trying to query for all users tagged with any of the tags in the collection tags

I'm using acts_as_taggable_on and I'm trying to query for all users tagged with any of the tags in the collection tags

Right now I'm doing:

tags.map(&:name).each { |name| @result.push User.tagged_with(name) }

Is there a way that I can do this in one query, and 开发者_如何学运维not tags.size queries? I'd appreciate any help.


Try this one:

User.tagged_with(tags.map(&:name), :any => true)

Hope it helps!

0

精彩评论

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