module TagDb::ClassMacros

Public Instance Methods

has_many_tags( opts={} ) click to toggle source
# File lib/tagutils/tags/active_record.rb, line 4
def has_many_tags( opts={} )
  puts "  [TagDb.has_many_tags] adding taggings n tags has_many assocs to model >#{name}<"

  has_many :taggings, class_name: 'TagDb::Model::Tagging', :as      => :taggable
  has_many :tags,     class_name: 'TagDb::Model::Tag',     :through => :taggings

  ### check: use tag_name instead of tag_key ???
  scope :with_tag, ->(tag_key){ joins(:tags).where('tags.key' => tag_key) }
end