This commit is contained in:
@@ -22,7 +22,7 @@ class Tag < ApplicationRecord
|
||||
has_many :parents, through: :reversed_tag_implications, source: :parent_tag
|
||||
|
||||
belongs_to :tag_name
|
||||
delegate :name, to: :tag_name
|
||||
delegate :name, to: :tag_name, allow_nil: true
|
||||
validates :tag_name, presence: true
|
||||
|
||||
enum :category, { deerjikist: 'deerjikist',
|
||||
@@ -51,6 +51,10 @@ class Tag < ApplicationRecord
|
||||
(self.tag_name ||= build_tag_name).name = val
|
||||
end
|
||||
|
||||
def has_wiki
|
||||
tag_name&.wiki_page.present?
|
||||
end
|
||||
|
||||
def self.tagme
|
||||
@tagme ||= find_or_create_by_tag_name!('タグ希望', category: 'meta')
|
||||
end
|
||||
@@ -107,8 +111,9 @@ class Tag < ApplicationRecord
|
||||
private
|
||||
|
||||
def nico_tag_name_must_start_with_nico
|
||||
if ((category == 'nico' && !(name.start_with?('nico:'))) ||
|
||||
(category != 'nico' && name.start_with?('nico:')))
|
||||
n = name.to_s
|
||||
if ((category == 'nico' && !(n.start_with?('nico:'))) ||
|
||||
(category != 'nico' && n.start_with?('nico:')))
|
||||
errors.add :name, 'ニコニコ・タグの命名規則に反してゐます.'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user