From ecd49992c2973cfd477cfbde881e2fc5c0eb52eb Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Fri, 17 Oct 2025 15:43:40 +0100 Subject: [PATCH 1/2] ci: add Rails 8.1.0.rc1 to test matrix --- .github/workflows/ci.yml | 5 +++-- Gemfile | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99d6e0b6..0d157429 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: jobs: test: runs-on: ubuntu-latest - + services: postgres: image: postgres:17-alpine @@ -26,7 +26,7 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 - + mysql: image: mysql:8 ports: @@ -47,6 +47,7 @@ jobs: - '3.4' rails: - '8.0' + - '8.1.0.rc1' steps: - name: Checkout diff --git a/Gemfile b/Gemfile index 80b33c68..82cdc1a3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,10 +5,11 @@ source 'https://rubygems.org' gemspec gem 'dotenv' -gem 'railties' gem 'with_advisory_lock', '>= 7' -gem 'activerecord', "~> #{ENV['RAILS_VERSION'] || '8.0'}" +rails_version = ENV['RAILS_VERSION'] || '8.0' +gem 'activerecord', "~> #{rails_version}" +gem 'railties', "~> #{rails_version}" platforms :mri, :truffleruby do # Database adapters From 493f0184032a30b96d713b2680a295dea7359d9f Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Fri, 17 Oct 2025 16:10:48 +0100 Subject: [PATCH 2/2] fix: add implicit_order_column for Rails 8.1+ compatibility Rails 8.1+ requires an implicit_order_column for models without a primary key to support ordering. Hierarchy tables don't have a primary key, so we set ancestor_id as the implicit order column. --- lib/closure_tree/support.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/closure_tree/support.rb b/lib/closure_tree/support.rb index c13676d0..3a0a8ae7 100644 --- a/lib/closure_tree/support.rb +++ b/lib/closure_tree/support.rb @@ -33,6 +33,9 @@ def hierarchy_class_for_model hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(model_class.superclass)) model_class_name = model_class.to_s hierarchy_class.class_eval do + # Rails 8.1+ requires an implicit_order_column for models without a primary key + self.implicit_order_column = 'ancestor_id' + belongs_to :ancestor, class_name: model_class_name belongs_to :descendant, class_name: model_class_name def ==(other)