mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 11:58:15 +08:00
There are times the LLM returns values that are too large to make sense. This adds a database limit on the column so it prevents the commit. (https://meta.discourse.org/t/category-description-in-french-broken/372397)
33 lines
944 B
Ruby
33 lines
944 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CategoryLocalization < ActiveRecord::Base
|
|
belongs_to :category
|
|
|
|
validates :locale, presence: true, length: { maximum: 20 }
|
|
validates :name, presence: true, length: { maximum: 50 }
|
|
validates :category_id, uniqueness: { scope: :locale }
|
|
|
|
after_commit :invalidate_site_cache
|
|
|
|
def invalidate_site_cache
|
|
I18n.with_locale(locale) { Site.clear_cache }
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: category_localizations
|
|
#
|
|
# id :bigint not null, primary key
|
|
# category_id :bigint not null
|
|
# locale :string(20) not null
|
|
# name :string(50) not null
|
|
# description :string(1000)
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_category_localizations_on_category_id (category_id)
|
|
# index_category_localizations_on_category_id_and_locale (category_id,locale) UNIQUE
|
|
#
|