sorbet-rails icon indicating copy to clipboard operation
sorbet-rails copied to clipboard

Disabling a builtin model plugin

Open Jamie5 opened this issue 4 years ago • 1 comments

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

Jamie5 avatar Feb 10 '21 01:02 Jamie5

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.

hdoan741 avatar Feb 10 '21 22:02 hdoan741