Sha256: 7413af8a30ed6851402e41eb7c07372724d050a4168087529dc138a0f44d42a8
Contents?: true
Size: 564 Bytes
Versions: 1
Compression:
Stored size: 564 Bytes
Contents
# encoding: utf-8 class Tagging < ActiveRecord::Base belongs_to :tag belongs_to :taggable, polymorphic: true validates :taggable_id, presence: true validates :taggable_type, presence: true validates :tag_id, presence: true, uniqueness: { scope: [: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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.5.1 | app/models/tagging.rb |