Skip to content

Trek::Taggable

Tag associations for any model, via the taxonomy models (installed by the taxonomies generator).

What it adds

  • has_many :taggings, as: :taggable, dependent: :destroy
  • has_many :tags, through: :taggings
  • tag_names — the tag names as an array of strings

Usage

ruby
class Article < ApplicationRecord
  include Trek::Taggable
end

article.tags << Tag.find_or_create_by(name: "Ruby", key: "ruby")
article.tag_names # => ["Ruby"]

Released under the MIT License.