Repository navigation
Conversation
Gems add methods to Rails classes lazily, e.g. responders runs
`ActiveSupport.on_load(:action_controller) { include
ActionController::RespondWith }`. The include ran inside a block, so
its reference attached to the enclosing namespace (or nothing) and
ActionController::Base never gained the module's methods.
Map include, extend and prepend inside an on_load block (bare, with
self as receiver, or through `send :include`) onto the classes that
run the hook. The hook-to-class table comes from the run_load_hooks
call sites in Rails 7.0 through 8.1; :action_controller runs on both
ActionController::Base and ActionController::API. Hooks whose payload
is not a class (:i18n, :after_initialize, ...) are left alone.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
The generic<X> left by Hash#fetch is the rbs >= 4.1.0 regression tracked in castwide#1227; fetch without a default leaks it the same way. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
The hook-to-class table depends on which Rails libraries define each hook, so it belongs with the Rails integration rather than in core. Conventions now supply it through Convention::Base#load_hook_targets, and Convention.load_hook_targets unions what every registered convention returns. With no convention supplying targets, mixins in on_load blocks map nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
Owner
Author
|
Claude: Replaced by iftheshoefritz/solargraph-rails#226, which maps on_load mixins in solargraph-rails and measures the same 15 of 23. |
apiology
added a commit
to iftheshoefritz/solargraph-rails
that referenced
this pull request
Oct 9, 2026
Rails integrations add modules to Rails classes inside
ActiveSupport.on_load(:hook) blocks, e.g. responders including
ActionController::RespondWith into ActionController::Base. Solargraph
attached those mixins to the enclosing namespace, so methods such as
respond_with were missing from controllers.
Register a :send node processor that maps include, extend and prepend
inside such a block onto the classes the hook runs on, taken from the
run_load_hooks call sites in Rails 7.0 through 8.1. Calls on self, with
no receiver, through send(:include, ...) or on the block parameter
(on_load(:x) { |base| base.include Foo }) all count.
This replaces doing the same in Solargraph core
(apiology/solargraph#147): no non-Rails activesupport gem calls
on_load.
Solargraph before 0.56.2 keeps one processor per node type, so
registering there would replace its own; the processor is only loaded
and registered where NodeProcessor supports chaining.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
apiology
added a commit
to iftheshoefritz/solargraph-rails
that referenced
this pull request
Oct 13, 2026
* Map mixins added in ActiveSupport.on_load blocks
Rails integrations add modules to Rails classes inside
ActiveSupport.on_load(:hook) blocks, e.g. responders including
ActionController::RespondWith into ActionController::Base. Solargraph
attached those mixins to the enclosing namespace, so methods such as
respond_with were missing from controllers.
Register a :send node processor that maps include, extend and prepend
inside such a block onto the classes the hook runs on, taken from the
run_load_hooks call sites in Rails 7.0 through 8.1. Calls on self, with
no receiver, through send(:include, ...) or on the block parameter
(on_load(:x) { |base| base.include Foo }) all count.
This replaces doing the same in Solargraph core
(apiology/solargraph#147): no non-Rails activesupport gem calls
on_load.
Solargraph before 0.56.2 keeps one processor per node type, so
registering there would replace its own; the processor is only loaded
and registered where NodeProcessor supports chaining.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
* Cover the on_load processor's guard branches
Add specs for the cases each guard rejects: non-constant mixin
arguments, send without a method name or with a string one, on_load
without an ActiveSupport receiver or a symbol hook, and Solargraph
versions where processors cannot be chained. Registration moves into
LoadHooks.register so that last case can be exercised.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
* Register the load hook processor from the entrypoint
Feature files under lib/solargraph/rails/ have no load-time side
effects; registration happens at the bottom of solargraph-rails.rb,
next to Convention.register.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was written by Claude Code on behalf of @apiology.
Builds on castwide#1378.
Problem: Methods that gems mix into Rails classes through load hooks are missing:
Rails apps lose responders, globalid, orm_adapter and turbo-rails' native navigation helpers, and an app's own
on_loadinitializers have no effect.Solution: Map
include,extendandprependinside anActiveSupport.on_load(:hook)block (bare,self., orsend :include) onto the classes that conventions report for that hook through a newConvention::Base#load_hook_targets;Convention.load_hook_targetsunions what every registered convention returns.Only mixins are mapped: methods defined or macros called inside the block are not. Hooks no convention maps are ignored, so with no plugin loaded nothing is mapped. Module names resolve as written, not against the block's lexical scope.
Where this belongs:
ActiveSupport.on_loadis ActiveSupport's API, but only Rails integrations call it. In a random sample of 357 rubygems.org gems depending on activesupport, none of the 190 that are not Rails-only in practice call it, while 14% of them (26 of 190; 95% CI 9.5–19%) useclass_attribute,mattr_*/cattr_*orconfig_accessor. So core keeps the generic block mechanism, and the hook-to-class table, which depends on Rails libraries, comes from plugins: solargraph-rails supplies it viaload_hook_targets.In the language server, gem pins are cached in a
solargraph cachesubprocess, so mixins from gems map there only with #149, which loads the workspace's plugins when caching gems.Test plan: measured before the table moved to plugins, with it in core; needs re-measuring with solargraph-rails supplying it. solargraph-rails 061a2009 definitions (Rails 8.0), against
gem-without-yard: of the 23 entries skipped for this reason, 9 now match (responders 7/9, orm_adapter 1/1, globalid 1/6) and 7 more resolve with real types where the definitions sayundefined(globalid 5, responders#responder?/#mimes_for_respond_to?as Boolean). The 7 turbo-rails entries need #144, sinceTurbo::Native::Navigationlives underapp/. No regressions across all 3133 entries.