ruby-on-railsacts-as-taggable-on

how to find entries with no tags using acts-as-taggable-on?


What's the Right Way(tm) to find the entries that have no tags?

I tried using Entry.tagged_with(nil) but it just returns an empty hash.

I need it so I can list the entries I still need to tag.

Thanks.


Solution

  • Without knowing the internals of acts-as-taggable-on I can't think of a neat way that doesn't involve looping queries or raw SQL. This is readable:

    need_to_tag = []
    
    Entry.all.each do |e|
      need_to_tag << e if e.tag_list.blank?
    end
    

    need_to_tag then holds any untagged Entries.