このコミットが含まれているのは:
2026-10-03 01:30:26 +09:00
コミット 927ce90adc
9個のファイルの変更、74行の追加、48行の削除
+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
class Language < ApplicationRecord
has_many :locales, foreign_key: :language_code, primary_key: :code
enum :code, ja: 'ja', en: 'en', fr: 'fr'
enum :code, ja: 'ja'
end
+3
ファイルの表示
@@ -0,0 +1,3 @@
class Region < ApplicationRecord
;
end
+2 -2
ファイルの表示
@@ -1,5 +1,5 @@
class Script < ApplicationRecord
has_many :locales, foreign_key: :language_code, primary_key: :code
has_many :locales, foreign_key: :script_code, primary_key: :code
enum :code, Jpan: 'Jpan', Latn: 'Latn'
enum :code, Jpan: 'Jpan'
end
+15 -13
ファイルの表示
@@ -250,20 +250,22 @@ class Tag < ApplicationRecord
language_code = locale.language_code
name = name.to_s.strip
tn = TagName.find_or_create_by!(language_code:, name:) do
_1.script_code = locale.script_code
_1.primary_flg = true
ApplicationRecord.transaction do
tn = TagName.find_or_create_by!(language_code:, name:) do
_1.script_code = locale.script_code
_1.primary_flg = true
end
tag = tn.tag
next tag if tag
tag = Tag.create!(tag_name_id: tn.id, category:)
tn.update!(tag:, primary_flg: true, canonical_id: nil, auto_generated: false)
generate_tag_names!(locale, tag, tn)
tag.association(:tag_names).reset
tag
end
tag = tn.tag
return tag if tag
tag = Tag.create!(tag_name_id: tn.id, category:)
tn.update!(tag:)
generate_tag_names!(locale, tag, tn)
tag.association(:tag_names).reset
tag
rescue ActiveRecord::RecordNotUnique
retry
end
+8 -1
ファイルの表示
@@ -11,6 +11,7 @@ class TagName < ApplicationRecord
validate :alias_must_not_have_wiki_page
validate :name_must_be_sanitised
validate :name_mustnt_start_with_nico
validate :generated_name_must_be_reserved
def primary? = primary_flg
@@ -22,7 +23,7 @@ class TagName < ApplicationRecord
names.map { |name|
tag_name = tns[name]
if !tag_name || tag_name.primary?
if !tag_name || tag_name.primary? || tag_name.tag_id.nil?
name
else
TagName.find_by(language_code: locale.language_code,
@@ -40,6 +41,12 @@ class TagName < ApplicationRecord
private
def generated_name_must_be_reserved
if !auto_generated && name.to_s.start_with?('Tag_#')
errors.add :name, 'タグの命名規則に反してゐます.'
end
end
def alias_name_must_not_have_prefix
if !(primary?) && name.to_s.include?(':')
errors.add :name, 'エーリアス名にプレフィクスを含むことはできません.'