I'm using acts-as-taggable-on. I have Article model:
class Article < ActiveRecord::Base
acts_as_taggable_on :tags
end
I know how to find all articles with tag "tag". According to README the solution is: Article.tagged_with("tag")
.
But how to find all Articles without any tags?
Use a classic SQL trick: left join then select lines where second ID is null.
Article.
joins(%Q{LEFT JOIN taggings ON taggings.taggable_id=articles.id AND taggings.taggable_type='Article'}).
where('taggings.id IS NULL')