Merge branch 'main' into '#106'

このコミットが含まれているのは:
2026-03-06 00:49:01 +09:00
コミット 560ddcc0ab
13個のファイルの変更449行の追加8行の削除
+21
ファイルの表示
@@ -0,0 +1,21 @@
class Deerjikist < ApplicationRecord
self.primary_key = :platform, :code
belongs_to :tag
validates :platform, presence: true
validates :code, presence: true
validates :tag_id, presence: true
validate :tag_must_be_deerjikist
enum :platform, nico: 'nico', youtube: 'youtube'
private
def tag_must_be_deerjikist
if tag && !(tag.deerjikist?)
errors.add :tag, 'タグはニジラー・カテゴリである必要があります.'
end
end
end
+9
ファイルの表示
@@ -24,6 +24,8 @@ class Tag < ApplicationRecord
has_many :tag_similarities, dependent: :delete_all
has_many :deerjikists, dependent: :delete_all
belongs_to :tag_name
delegate :wiki_page, to: :tag_name
@@ -42,6 +44,7 @@ class Tag < ApplicationRecord
validate :nico_tag_name_must_start_with_nico
validate :tag_name_must_be_canonical
validate :category_must_be_deerjikist_with_deerjikists
scope :nico_tags, -> { where(category: :nico) }
@@ -154,4 +157,10 @@ class Tag < ApplicationRecord
errors.add :tag_name, 'tag_names へは実体を示す必要があります.'
end
end
def category_must_be_deerjikist_with_deerjikists
if !(deerjikist?) && deerjikists.exists?
errors.add :category, 'ニジラーと紐づいてゐるタグはニジラー・カテゴリである必要があります.'
end
end
end