Thanks Solomon for your solution ! It works great!
I'd like to use your solution as a scope (because I'd like to make a search not based only on tags).
The problem is that the "all" method breaks chaining scope.
I tried to make a scope like this, but doesn't work (not the expected result) :(
Thanks Solomon for your solution ! It works great!
I'd like to use your solution as a scope (because I'd like to make a search not based only on tags).
The problem is that the "all" method breaks chaining scope.
I tried to make a scope like this, but doesn't work (not the expected result) :(
scope :tagged_with, lambda { |names|
joins(:taggings,:tags).where(tags: {name: names}).group('articles.id').having(['COUNT(*) >= ?', names.length])
}
Any idea ?
+1 for an update ;)