System File Override

Hello. Climbed the entire forum, but did not find the answer to your question.
Essence: I am writing a plugin on the Ruby, I need to override the file from the root Discourse app/ controllers/search.rb, how is all this implemented in the plugin itself?
Example: I deleted users from the search response, but I cut out this functionality from the project root, but I need to use a plugin
On the screen: deleted users that are on the right57

You can just redefine the methods to override them … Ruby takes the definitions in order and your plugin code is evaluated last.

e.g. in my plugin, ‘onebox assistant’, I redefine external_onebox in plugin.rb

after_initialize do

  Oneboxer.module_eval do

    def self.external_onebox(url)

       # my new code goes here

More from fellow plugin devs here:

3 Likes