# 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:** 1
**Showing post:** 2

<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…

---

_[View the full topic](https://meta.discourse.org/t/system-file-override/112513)._
