Module: Alchemy::Taggable::ClassMethods

Defined in:
lib/alchemy/taggable.rb

Instance Method Summary collapse

Instance Method Details

#tag_countsObject

Returns all unique tags


35
36
37
38
# File 'lib/alchemy/taggable.rb', line 35

def tag_counts
  Gutentag::Tag.distinct.joins(:taggings)
    .where(gutentag_taggings: {taggable_type: name})
end

#tagged_with(names) ⇒ Object

Find all records matching all of the given tags. Separate multiple tags by comma.


27
28
29
30
31
32
# File 'lib/alchemy/taggable.rb', line 27

def tagged_with(names)
  if names.is_a? String
    names = names.split(/,\s*/)
  end
  super(names: names, match: :all)
end