I have a Ticket model which has_many :tags. I would like to find all tickets that have tags where tag.label is in an array of strings.
Here’s what i’m trying at the moment:
tags = params[:tags].split(',')
if tags.count > 0 then
t = t.scoped(include: :tag).where('tags.label' => tags.map(&:label))
end
Something like this should work:
Or as a scope:
The problem with Mikhail Nikalyukin’s solution is
.map(&:label). That part is not necessary.