在插件中覆盖现有的Discourse方法

刚开始接触 discourse 和 Rails 开发。我正在本地使用 Dev Container 环境(在 VS Code 中)。指南和文档很有帮助。

我想知道是否有人能提供关于如何覆盖核心 discourse 类的方法,特别是在本地开发环境中使其持久化。

在我的插件中,我试图覆盖核心 discourse TopicEmbed 类中的一个方法。(使用 @angus 上面很好地记录的通用方法。)它在我重建和重新加载 VS Code 时工作一次,但在后续的 http 请求中,我的覆盖从未被调用。

我的覆盖定义在 /plugins/my-plugin/app/models/override.rb 中,我使用 require_relative 将此文件包含在我的 plugin.rb 中。

#override.rb:
class ::TopicEmbed

  # 一个将预置到 TopicEmbed.singleton_class 的模块
  module TopicEmbedOverrideModule
    # TopicEmbed 中的方法
    def first_paragraph_from(html)
      Rails.logger.info(“我的覆盖正在发生! ”)

      # 继续执行 TopicEmbed 提供的原始实现。
      super

    end
  end

  # 在此处进行预置
  singleton_class.prepend TopicEmbedOverrideModule
end

我怀疑我的持久化挑战可能与我的开发环境以及 Ruby 代码的编译/缓存方式有关。
我也尝试了 rm -rf tmp; bin/ember-cli -ubundle exec rake tmp:cache:clear