Discourse Plugins and Rails 6 config/initializers Question

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):

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:

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:

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.