# Can you override 'any' file in Discourse via a plugin?

**URL:** <https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836>\
**Category:** Development\
**Created:** [February 16, 2021, 12:15am UTC](https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836 "2021-02-16T00:15:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)\
**Post date:** [February 16, 2021, 12:15am UTC](https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836/1 "2021-02-16T00:15:48Z")

</div>

I thought this was the case but on trying it recently it didn’t work (I also searched for an answer here and Google but didn’t find anything concrete, so hopefully this might help someone in future).

It’s been a while since I read about plugins but from memory does it go something like this?

- `rails g plugin NAME`
- locate the file you want to change
- change it first to test it does what you need, if it does..
- copy it into the same directory in your plugin
- make your changes and the changes should take effect

---

<div class="post-metadata">

**Author:** ![hawm](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@hawm](https://meta.discourse.org/u/hawm)\
**Post date:** [February 16, 2021, 5:44am UTC](https://meta.discourse.org/t/can-you-override-any-file-in-discourse-via-a-plugin/179836/2 "2021-02-16T05:44:09Z")

</div>

No, you override class/method rather a file, so filename may dosn’t matter. If you don’t know about the plugin structure you can read some offical plugin source code.

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