Sha256: 78dd3cd8c791c8310e1a0ff00309a49f3e03ca52d4963a0d6132da06b17cbe43
Contents?: true
Size: 587 Bytes
Versions: 6
Compression:
Stored size: 587 Bytes
Contents
# frozen_string_literal: true class Tagging < ApplicationRecord belongs_to :tag belongs_to :taggable, polymorphic: true, touch: true validates :taggable_id, presence: true validates :taggable_type, presence: true validates :tag_id, presence: true, uniqueness: { scope: %i[taggable_type taggable_id] } def self.tagged_class(taggable) ActiveRecord::Base.send( :class_of_active_record_descendant, taggable.class ).to_s end def self.find_taggable(tagged_class, tagged_id) tagged_class.constantize.find(tagged_id) end end
Version data entries
6 entries across 6 versions & 1 rubygems