このコミットが含まれているのは:
2026-09-22 20:16:30 +09:00
コミット a0c2788e00
8個のファイルの変更198行の追加42行の削除
+7 -2
ファイルの表示
@@ -6,8 +6,13 @@ class ExternalTag < ApplicationRecord
has_many :posts, through: :post_external_tags
has_many :nico_tag_versions, foreign_key: :tag_id, inverse_of: :external_tag
has_many :nico_tag_relations, foreign_key: :tag_id, dependent: :destroy
has_many :linked_tags, through: :nico_tag_relations, source: :nico_tag
has_many :nico_tag_relations,
foreign_key: :nico_tag_id,
inverse_of: :nico_tag,
dependent: :destroy
has_many :linked_tags, through: :nico_tag_relations, source: :tag
def snapshot_linked_tag_names
linked_tags.joins(:tag_name).order('tag_names.name').pluck('tag_names.name')
+5 -2
ファイルの表示
@@ -1,6 +1,9 @@
class NicoTagRelation < ApplicationRecord
belongs_to :nico_tag, class_name: 'Tag'
belongs_to :tag, class_name: 'Tag'
belongs_to :nico_tag,
class_name: 'ExternalTag',
foreign_key: :nico_tag_id,
inverse_of: :nico_tag_relations
belongs_to :tag, class_name: 'Tag', foreign_key: :tag_id
validates :nico_tag_id, presence: true
validates :tag_id, presence: true
+5 -2
ファイルの表示
@@ -28,8 +28,11 @@ class Tag < ApplicationRecord
has_many :post_tags, inverse_of: :tag
has_many :posts, through: :post_tags
has_many :nico_tag_relations, foreign_key: :nico_tag_id, dependent: :destroy
has_many :linked_tags, through: :nico_tag_relations, source: :tag
has_many :reversed_nico_tag_relations,
class_name: 'NicoTagRelation',
foreign_key: :nico_tag_id,
dependent: :destroy
has_many :linked_nico_tags, through: :reversed_nico_tag_relations, source: :nico_tag
has_many :tag_implications, foreign_key: :parent_tag_id, dependent: :destroy
has_many :children, through: :tag_implications, source: :tag