From e7d5d0b2c32b172ecdaa80555bf5804043fd87a0 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 27 Jun 2026 00:32:17 +0200 Subject: Fix I18n::InvalidLocale :root errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix Page.find(self.head) → self.head in node.rb wipe_draft! - Migration to delete 407 spurious 'root' locale records from page_translations (Globalize artefact, all had nil titles and duplicate de/en translations existed for all affected pages) --- app/models/node.rb | 2 +- ...20260626222953_remove_root_locale_from_page_translations.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20260626222953_remove_root_locale_from_page_translations.rb diff --git a/app/models/node.rb b/app/models/node.rb index a3ef23a..59a9d7c 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -137,7 +137,7 @@ class Node < ApplicationRecord end return unless self.head return unless self.draft.updated_at < 1.day.ago - return if Page.find(self.head).has_changes_to? self.draft + return if self.head.has_changes_to? self.draft self.draft.destroy self.draft_id = nil diff --git a/db/migrate/20260626222953_remove_root_locale_from_page_translations.rb b/db/migrate/20260626222953_remove_root_locale_from_page_translations.rb new file mode 100644 index 0000000..51fcfbc --- /dev/null +++ b/db/migrate/20260626222953_remove_root_locale_from_page_translations.rb @@ -0,0 +1,10 @@ +class RemoveRootLocaleFromPageTranslations < ActiveRecord::Migration[7.2] + def up + count = execute("DELETE FROM page_translations WHERE locale = 'root'").cmd_tuples + say "Deleted #{count} root locale records from page_translations" + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end -- cgit v1.3