Find documents tagged with all tags passed as a parameter, given
# as an Array or a String using the configured separator.
#
# @example Find matching all tags in an Array.
# Article.tagged_with(['ruby', 'mongodb'])
# @example Find matching all tags in a String.
# Article.tagged_with('ruby, mongodb')
def tagged_with(context, tags)
tags = convert_string_to_array(tags, get_tag_separator_for(context)) if tags.is_a? String
array_field = tag_options_for(context)[:array_field]
any_in(array_field => tags)
end
I want to find related documents using the tags... which wouldn't work with all_in, so I updated it to any_in and it seems to work fine.
Article.tagged_with(['ruby', 'mongodb'])
Maybe this should be an option?
Article.tagged_with(['ruby', 'mongodb'], :match_all => true)
Article.tagged_with(['ruby', 'mongodb'], :any => true)
Find documents tagged with all tags passed as a parameter, given