# 「AI検索の発見」設定の切り替えが機能しない

**URL:** https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135
**Category:** Bug
**Tags:** ai
**Created:** [2025 年 12 月 12 日午前 9:57 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135 "2025-12-12T09:57:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025 年 12 月 12 日午前 9:57 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/1 "2025-12-12T09:57:29Z")

</div>

インターフェース設定に設定があることは知っていますが、どういうわけか私には機能しません。

  
「変更を保存しました」と表示されますが、データベースの値はまだ「true」のままで、リロードすると再び有効になります。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2025 年 12 月 12 日午前 11:53 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/3 "2025-12-12T11:53:48Z")

</div>

奇妙ですね。railsで見てみましたか？

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025 年 12 月 12 日午前 11:59 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/4 "2025-12-12T11:59:56Z")

</div>

それをどうやるのですか？Metaは私のフォーラムではありません

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2025 年 12 月 12 日午後 1:09 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/5 "2025-12-12T13:09:51Z")

</div>

`modifyClass` を使うのに躊躇していますが、これより良い方法が思いつきません 🤔 (cc @david / @cvx)

> <https://github.com/discourse/discourse/pull/36658>
>
> The "Enable AI search discoveries" checkbox in user preferences wasn't persistin…g changes. The UI showed "saved" but the value never reached the database.
> 
> The Interface controller's \`saveAttrNames\` is a computed property that returns a new array on each access. While the plugin called \`addSaveableUserOptionField()\`, this only registers the field with the User model. The controller filters which fields to save via \`saveAttrNames\`, and since \`ai\_search\_discoveries\` wasn't in that list, it was excluded from the save request.
> 
> Fix by using \`modifyClass\` to extend the controller's \`save()\` action, pushing \`ai\_search\_discoveries\` to \`saveAttrNames\` at the moment of saving before calling the parent method.
> 
> Ref - meta/t/391135

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2025 年 12 月 12 日午後 1:10 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/6 "2025-12-12T13:10:43Z")

</div>

確かに、`modifyClass` は特にコアプラグインでは理想的ではありません。

最善の方法は、コアに新しい `valueTransformer` を導入し、このようなことを行うための「サポートされている」方法を持つことです。

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2025 年 12 月 12 日午後 2:44 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/7 "2025-12-12T14:44:44Z")

</div>

> [@david](#):
>
> コアに新しい valueTransformer を導入するのが最善でしょう

これはどうでしょうか？

> <https://github.com/discourse/discourse/pull/36658/commits/e3a16f952b7283a4365adc1b097d6960e40c93d7>
>
> Previously, plugins needed to use \`modifyClass\` to extend the
> \`saveAttrNames\` li…st in preference controllers. This approach is
> not ideal as it overrides controller methods and can be fragile.
> 
> This commit introduces a \`preferences-save-attributes\` value
> transformer that provides a supported way for plugins to add
> custom fields to any preference page's save list.
> 
> The transformer passes a \`page\` context parameter so plugins can
> target specific preference pages:
> 
> \`\`\`javascript
> api.registerValueTransformer(
> "preferences-save-attributes",
> ({ value: attrs, context }) =\> {
> if (context.page === "interface") {
> attrs.push("my\_custom\_field");
> }
> return attrs;
> }
> );
> 
> Available pages: account, emails, interface, navigation-menu,
> notifications, profile, tags, tracking, users.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2025 年 12 月 12 日午後 11:48 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/8 "2025-12-12T23:48:52Z")

</div>

ありがとうございます。ついに無効になりました 🎊

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2025 年 12 月 13 日午前 8:01 UTC](https://meta.discourse.org/t/toggling-the-ai-search-discoveries-preference-doesnt-work/391135/9 "2025-12-13T08:01:00Z")

</div>


