Skip to content

Fix STI resolution for models inheriting directly from ActiveRecord::Base#34

Merged
ngan merged 1 commit intomainfrom
fix-sti-base-table-model-for-direct-ar-base-inheritance
Mar 4, 2026
Merged

Fix STI resolution for models inheriting directly from ActiveRecord::Base#34
ngan merged 1 commit intomainfrom
fix-sti-base-table-model-for-direct-ar-base-inheritance

Conversation

@robbiegill
Copy link
Contributor

Summary

  • Fixed base_table_model in SqlSubscriber to stop traversal at ActiveRecord::Base in addition to abstract classes
  • Previously, models whose inheritance chain reached ActiveRecord::Base without an intermediate abstract class (like ApplicationRecord) would cause a NoMethodError
  • Added test coverage with Gadget < ActiveRecord::Base and STI subclasses Phone/Tablet

Test plan

  • Existing STI test (Vehicle/Car/Truck via ApplicationRecord) still passes
  • New test for direct AR::Base inheritance (Gadget/Phone/Tablet) passes
  • Full suite: 158 examples, 0 failures

🤖 Generated with Claude Code

…Base

The base_table_model method previously only stopped traversal when
encountering an abstract superclass. Models whose inheritance chain
reaches ActiveRecord::Base without passing through an abstract class
(like ApplicationRecord) would walk past AR::Base and raise NoMethodError.

Add ActiveRecord::Base as an additional stop condition so STI resolution
works for both inheritance patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robbiegill robbiegill marked this pull request as ready for review March 4, 2026 19:40
@robbiegill robbiegill requested a review from ngan March 4, 2026 19:41
@ngan ngan merged commit 395d869 into main Mar 4, 2026
10 checks passed
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.

2 participants