James
James

Reputation: 5403

acts_as_taggable_on: query for users tagged with any of these 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.

Upvotes: 1

Views: 256

Answers (1)

jpemberthy
jpemberthy

Reputation: 7533

Try this one:

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

Hope it helps!

Upvotes: 1

Related Questions