Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Disabling a builtin model plugin #401

Open
Jamie5 opened this issue Feb 10, 2021 · 1 comment
Open

Disabling a builtin model plugin #401

Jamie5 opened this issue Feb 10, 2021 · 1 comment

Comments

@Jamie5
Copy link

Jamie5 commented Feb 10, 2021

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

@hdoan741
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants