# Discourse Plugins and Rails 6 config/initializers Question

**URL:** <https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373>\
**Category:** Development\
**Created:** [October 27, 2020, 11:34am UTC](https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373 "2020-10-27T11:34:52Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [November 22, 2020, 2:47pm UTC](https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373/25 "2020-11-22T14:47:09Z")

</div>

> [@fzngagan](#):
>
> Yeah, I would love those rails perks being ported to discourse plugins. One of my personal favourite would be able to live reload the ruby files without restarting the server.

Hey @fzngagan, I am certainly not a “rubyist” and have a lot less experience with Rails than most Discourse plugin developers; but having said that: maybe you could get by with something like this in the future if you need to reload files in your plugin without restarting the application in production (or development):

```plaintext
after_initialize do

  # change the following to your controller of choice
  # or use the application controller if you need to

  ApplicationController.class_eval do
    before_action :do_my_stuff

    def do_my_stuff
      load File.open(FAIZAANS_FAV_FILE)
    end
  end
end

```

This will reload the files as expected

I am currently using this on a plugin like so, and it works as expected:

```plaintext
after_initialize do

  Admin::AdminController.class_eval do
    before_action :do_neo_plugin_info

    def do_neo_plugin_info
      load File.open(PLUGIN_LOGIC)
    end
  end
end

```

I am currently using this code in a plugin I have been working on from time-to-time which displays the names of the containers which is parsed from `ENV["DATA_NAME"`] and also the disk space parsed from some system code using `df` and `grep`.

#### In our admin views:

 ![Screen Shot 2020-11-22 at 9.36.05 PM](https://global.discourse-cdn.com/meta/original/3X/4/3/430480bc5469a3a3dc4ad59dff1593efd0ce869c.jpeg)

As mentioned, I am not a Rubyist by any means; but this method works for me.

I looked at the plugin code in `instance.rb` and after some different trials and errors, I decided to go with the `class_eval` code above, and it might not be the preferred way of doing things, but it certainly works for me.

For example, if I reload the page after deleting a lot of Discourse backups, the disk space indicator changes as expected.

---

_[View the full topic](https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373)._
