From 3dbf522783dfce496884e05559dc962cae4b1e1b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 6 Jul 2026 16:59:19 +0200 Subject: Apply slug immediately for never-published nodes staged_slug existed to protect a live public URL from changing until an editor explicitly publishes - correct once a node has a head, but nodes_controller#update wrote to it unconditionally, so a brand-new node being renamed before its first-ever publish showed a stale slug in previews (e.g. nodes#new's resulting-path preview) that silently diverged from what would actually go live. Node#staged_slug= now applies directly to slug when head is blank - nothing is live yet, so there's nothing to protect. Once head is present, defers to staged_slug exactly as before. Verified both paths directly: a never-published node's slug now updates immediately, and an already-published node's rename still stays deferred until the next publish, unchanged from existing behavior. --- app/models/node.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/models/node.rb') diff --git a/app/models/node.rb b/app/models/node.rb index ba94e2a..2177f15 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -94,6 +94,14 @@ class Node < ApplicationRecord self.draft.reload end + def staged_slug=(value) + if head.blank? + self.slug = value + else + super + end + end + def publish_draft! # Return nil if nothing to publish and no staged changes return nil unless self.draft || staged_slug || staged_parent_id -- cgit v1.3