# System File Override

**URL:** https://meta.discourse.org/t/system-file-override/112513
**Category:** Development
**Created:** [March 25, 2019, 4:08pm UTC](https://meta.discourse.org/t/system-file-override/112513 "2019-03-25T16:08:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Yauheni33](https://avatars.discourse-cdn.com/v4/letter/y/b3f665/32.png) [@Yauheni33](https://meta.discourse.org/u/Yauheni33)
#### Post date: [March 25, 2019, 4:08pm UTC](https://meta.discourse.org/t/system-file-override/112513/1 "2019-03-25T16:08:25Z")

</div>

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 right

 ![57](https://global.discourse-cdn.com/meta/original/3X/5/6/563647516f1207b51df13df5d2d727c4150a2e13.png)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [March 25, 2019, 4:28pm UTC](https://meta.discourse.org/t/system-file-override/112513/2 "2019-03-25T16:28:11Z")

</div>

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`

```plaintext
after_initialize do

  Oneboxer.module_eval do

    def self.external_onebox(url)

       # my new code goes here

```

More from fellow plugin devs here:

> [@Override existing Discourse methods in plugins](https://meta.discourse.org/t/tips-for-overriding-existing-discourse-methods-in-plugins/83389):
>
> I’ve been running into a bunch of instances recently of needing to override existing ruby methods from plugins, and thought I’d share my best practices here. Overriding an instance method class ::TopicQuery module BabbleDefaultResults def default\_results(options={}) super(options).where('archetype \<\> ?', Archetype.chat) end end prepend BabbleDefaultResults end Here I’m removing chat topics from an instance method which is returning a list of topics. The module name BabbleD…
