From 3b507bb281258b9cf32fae937c9cb07dce5a28d2 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Thu, 24 Jul 2025 10:02:00 +0100 Subject: [PATCH] fix: restore proper deprecation for database_less configuration The database_less configuration option was removed in v9.1.0 without proper deprecation, causing deployments to fail when upgrading if they had this configuration in their production.rb or initializers. This change restores backward compatibility by: - Adding a minimal Configuration class that captures the deprecated database_less option - Showing specific deprecation warnings when database_less is used - Making the option a no-op (always returns false) since it's no longer needed - Providing clear migration guidance for users to remove their configuration The deprecation timeline indicates removal in v10.0.0, giving users time to migrate away from this obsolete configuration without breaking deployments. Also includes improvements to HasClosureTree include order dependency and README formatting fixes to use inline return value comments. Fixes the missing deprecation that was introduced when migrating to Zeitwerk. --- README.md | 39 ++++++++------------- lib/closure_tree.rb | 15 +++++--- lib/closure_tree/association_setup.rb | 50 +++++++++++++++++++++++++++ lib/closure_tree/configuration.rb | 22 ++++++++++++ lib/closure_tree/has_closure_tree.rb | 9 +++-- lib/closure_tree/model.rb | 39 --------------------- 6 files changed, 104 insertions(+), 70 deletions(-) create mode 100644 lib/closure_tree/association_setup.rb create mode 100644 lib/closure_tree/configuration.rb diff --git a/README.md b/README.md index 16a86ba..89c7d05 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ Note that closure_tree only supports ActiveRecord 7.2 and later, and has test co Make sure you check out the [large number of options](#available-options) that `has_closure_tree` accepts. + **Note:** The `acts_as_tree` alias is only created if your model doesn't already have a method with that name. This prevents conflicts with other gems like the original `acts_as_tree` gem. + **IMPORTANT: Make sure you add `has_closure_tree` _after_ `attr_accessible` and `self.table_name =` lines in your model.** @@ -156,10 +158,10 @@ Then: ```ruby grandparent.self_and_descendants.collect(&:name) -=> ["Grandparent", "Parent", "First Child", "Second Child", "Third Child", "Fourth Child"] +#=> ["Grandparent", "Parent", "First Child", "Second Child", "Third Child", "Fourth Child"] child1.ancestry_path -=> ["Grandparent", "Parent", "First Child"] +#=> ["Grandparent", "Parent", "First Child"] ``` ### find_or_create_by_path @@ -204,19 +206,16 @@ d = Tag.find_or_create_by_path %w[a b c d] h = Tag.find_or_create_by_path %w[e f g h] e = h.root d.add_child(e) # "d.children << e" would work too, of course -h.ancestry_path -=> ["a", "b", "c", "d", "e", "f", "g", "h"] +h.ancestry_path #=> ["a", "b", "c", "d", "e", "f", "g", "h"] ``` When it is more convenient to simply change the `parent_id` of a node directly (for example, when dealing with a form `