sorbet-rails
sorbet-rails copied to clipboard
Disabling a builtin model plugin
Is there a way to disable a builtin model plugin?
The use case is to disable active_record_named_scope
, because I want to define my own with more specific parameters, but simply adding a rbi file with the desired definition results in Method XYZ.the_scope redefined with argument args as a splat argument https://srb.help/4010
.
I tried putting the following in config/initializers/sorbet_rails.rb
but it did not appear to work.
SorbetRails.configure do |config|
config.enabled_model_plugins.delete(:active_record_named_scope)
end
(from what I can tell (but am not sure), there is a call to register_configured_plugins
even before we run the configuration code)
Note: a workaround seems to be SorbetRails::ModelRbiFormatter.get_plugins.delete(SorbetRails::ModelPlugins::ActiveRecordNamedScope)
in the config, though I guess this is undocumented and not guaranteed to work forever
Thank you. I'll triage this. It does look like we call register_configured_plugins
in railtie's initialize. I'll look into if we can change where this call is called to fix the bug.
For the time being, please feel free to use the workaround you've identified. Likely it'll keep working. I'll let you know if any change may affect it.