如何通过插件自定义/覆盖主题监护人

Okay. I think I found my answer. I just have to implement the “can_create_topic?” method in module ::TopicGuardian and it will automatically change TopicGuardian’s behavior without requiring to inject or registering it somewhere. Also, I can use super method inside my override method so that I don’t have to always manually keep it in sync with the original method in case that gets changed.

Got help from this topic: Overriding user_guardian.rb in a plugin (no fork necessary!)

2 个赞