Discourse Plugins and Rails 6 config/initializers Question

I guess I have mislead you in posts above. reloadable_patch is helpful for discourse development, but @david explained it’s use very well:


Anything inside the after_initialize block of plugin.rb is only loaded during application boot, and not on subsequent reloads.

So, assuming you want to add something to the user serializer. The normal behavior would be like:

At boot:

  • Discourse loads user_serializer.rb
  • Discourse loads plugin.rb , which has an override for user_serializer

At reload:

  • Discourse reloads user_serializer.rb
  • (the plugin.rb patch is not reloaded, the plugin override is lost)

With our reloadable_patch system:

At boot:

  • Discourse loads user_serializer.rb
  • Discourse loads plugin.rb and registers the reloadable_patch for the user_serializer
  • The reloadable patches are executed

At reload:

  • Discourse reloads user_serlializer.rb
  • The reloadable patches are executed
  • (yay, the plugin override is still working)
6 Likes