Class: Tagging
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Tagging
- Defined in:
- app/models/tagging.rb
Overview
== Schema Information
Table name: taggings
Database name: primary
id :integer not null, primary key
context :string(255)
taggable_type :string(255)
tagger_type :string(255)
created_at :datetime
tag_id :integer
taggable_id :integer
tagger_id :integer
Indexes
index_taggings_on_context (context)
index_taggings_on_tag_id_and_taggable_type (tag_id,taggable_type)
index_taggings_on_taggable (taggable_type,taggable_id)
index_taggings_on_taggable_id_and_taggable_type_and_context (taggable_id,taggable_type,context)
index_taggings_on_taggable_id_type_and_tag_id (taggable_id,taggable_type,tag_id)
index_taggings_on_tagger_id_and_tagger_type (tagger_id,tagger_type)
taggings_idx (tag_id,taggable_id,taggable_type,context,tagger_id,tagger_type) UNIQUE
taggings_idy (taggable_id,taggable_type,tagger_id,context)
Foreign Keys
fk_rails_... (tag_id => tags.id) ON DELETE => cascade
Constant Summary collapse
- TAGGABLE_TYPES =
Models that include the Taggable concern (includes STI subclasses)
%w[ Article Post ArticleFaq ArticleTechnical ArticleTraining ArticleProcedure Showcase DigitalAsset Image Video SketchfabModel FloorPlanDisplay Item ProductLine ActivityType LocatorRecord ].freeze
Instance Attribute Summary collapse
- #tag_id ⇒ Object readonly
Belongs to collapse
Class Method Summary collapse
-
.for_tag ⇒ ActiveRecord::Relation<Tagging>
A relation of Taggings that are for tag.
-
.for_taggable ⇒ ActiveRecord::Relation<Tagging>
A relation of Taggings that are for taggable.
-
.for_type ⇒ ActiveRecord::Relation<Tagging>
A relation of Taggings that are for type.
-
.taggable_types ⇒ Object
Get all distinct taggable types currently in use.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Attribute Details
#tag_id ⇒ Object (readonly)
55 |
# File 'app/models/tagging.rb', line 55 validates :tag_id, presence: true |
Class Method Details
.for_tag ⇒ ActiveRecord::Relation<Tagging>
A relation of Taggings that are for tag. Active Record Scope
64 |
# File 'app/models/tagging.rb', line 64 scope :for_tag, ->(tag) { where(tag: tag) } |
.for_taggable ⇒ ActiveRecord::Relation<Tagging>
A relation of Taggings that are for taggable. Active Record Scope
65 |
# File 'app/models/tagging.rb', line 65 scope :for_taggable, ->(taggable) { where(taggable: taggable) } |
.for_type ⇒ ActiveRecord::Relation<Tagging>
A relation of Taggings that are for type. Active Record Scope
63 |
# File 'app/models/tagging.rb', line 63 scope :for_type, ->(type) { where(taggable_type: type) } |
.taggable_types ⇒ Object
Get all distinct taggable types currently in use
68 69 70 |
# File 'app/models/tagging.rb', line 68 def self.taggable_types distinct.pluck(:taggable_type).sort end |
Instance Method Details
#taggable ⇒ Taggable
53 |
# File 'app/models/tagging.rb', line 53 belongs_to :taggable, polymorphic: true |