# plugin.rb 中的 \`add\_to\_class()\` 方法未被调用

**URL:** <https://meta.discourse.org/t/method-add-to-class-in-plugin-rb-is-not-being-called/243302>\
**Category:** Development\
**Created:** [2022年十月30日 02:05 UTC](https://meta.discourse.org/t/method-add-to-class-in-plugin-rb-is-not-being-called/243302 "2022-10-30T02:05:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoothSinger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/soothsinger/32/273050_2.png) [@SoothSinger](https://meta.discourse.org/u/SoothSinger)\
**Post date:** [2022年十月30日 02:05 UTC](https://meta.discourse.org/t/method-add-to-class-in-plugin-rb-is-not-being-called/243302/1 "2022-10-30T02:05:23Z")

</div>

大家好，

我正在尝试通过 `add_to_tag` 向标签添加值，但根据我的观察，当我加载带有标签的主题时，它没有被调用。

另一方面，我可以看到当执行以下操作时，该方法会被调用：

- `add_to_class(:category, :value)` 用于类别
- `add_to_class(:topic, :value)` 用于主题

但是，当执行以下操作时，则不会：

- `add_to_class(:tags, :value)`
- `add_to_class(:topic_tag, :value)`

我在这里错过了什么？也许是因为您无法向标签添加自定义字段？

此致，  
SS
