Skip to content

Stop assigning validation_context in sane_ancestor_ids? - #769

Open
SAY-5 wants to merge 1 commit into
stefankroes:masterfrom
SAY-5:drop-validation-context-writer
Open

Stop assigning validation_context in sane_ancestor_ids?#769
SAY-5 wants to merge 1 commit into
stefankroes:masterfrom
SAY-5:drop-validation-context-writer

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 16, 2026

Copy link
Copy Markdown

Description

Rails main removed the private validation_context= writer (rails/rails#58220), so sane_ancestor_ids? now raises NoMethodError whenever a node with descendants is moved or check_ancestry_integrity! runs. The context juggling was only there to give a cleaner error and nothing in the method reads it (the validators are invoked directly through validate_each), so this drops it rather than reaching into the new internal ValidationContext object. Fixes #766

Before

child.update!(parent: nil) on Rails main: NoMethodError: undefined method 'validation_context=' for an instance of Node

After

Move and integrity check work on Rails main, behavior unchanged on released Rails.

Type of Change

  • Bug fix

Checklist

  • My code follows the style guidelines (e.g., RuboCop)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally (bundle exec rake test)

How Has This Been Tested?

DB=sqlite3 bundle exec rake test on the default Gemfile, 258 runs 0 failures. The existing sane_ancestor_ids? tests in the materialized path suites cover the method; Rails main is not in the appraisal matrix so the failing path itself is not exercised in CI.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NoMethodError: undefined method 'validation_context=' on Rails main (removed in rails/rails#58220)

1 participant