RailsCasts Pro episodes are now free!

Learn more or hide this

krichtof's Profile

GitHub User: krichtof

Site: http://www.robiandco.org

Comments by krichtof

Avatar

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 ?