# 无法在 Discourse 3.5.0.beta5-dev 的 Rails 控制台中批量暂停/停用用户

**URL:** <https://meta.discourse.org/t/unable-to-bulk-suspend-deactivate-users-in-rails-console-on-discourse-3-5-0-beta5-dev/367571>\
**Category:** Support\
**Tags:** rails-console\
**Created:** [2025年五月26日 01:46 UTC](https://meta.discourse.org/t/unable-to-bulk-suspend-deactivate-users-in-rails-console-on-discourse-3-5-0-beta5-dev/367571 "2025-05-26T01:46:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)\
**Post date:** [2025年五月26日 01:46 UTC](https://meta.discourse.org/t/unable-to-bulk-suspend-deactivate-users-in-rails-console-on-discourse-3-5-0-beta5-dev/367571/1 "2025-05-26T01:46:01Z")

</div>

大家好，

我正在尝试通过 Rails 控制台批量暂停/停用我的 Discourse 实例（版本 **3.5.0.beta5-dev** ）上的用户，但遇到了一个持续存在的问题。 我试图排除我的管理员帐户 (`hoangthai`，用户 ID `100`)，并以自定义理由“Chưa gia hạn tài khoản”（帐户续订待定）永久暂停所有其他活跃的非管理员/非版主用户。

我已经尝试了几种基于常用 Discourse 控制台命令和调试建议的方法，但即使 `suspended_at` 和 `suspended_till` 可能会被设置，帐户仍然 `active: true`。

以下是我尝试过的方法以及错误/结果的细分：

**我的目标：** 永久暂停所有用户（除了 `hoangthai`，ID 100），理由是“Chưa gia hạn tài khoản”（帐户续订待定）。

**尝试与问题：**

1. **初始尝试（直接设置 `suspend_reason`、`suspended_at`、`suspended_till`）：**

2. **第二次尝试（使用为较新版本建议的 `UserSuspension.suspend_user`）：**

3. **第三次尝试（将类名更正为 `UserSuspender`）：**

4. **第四次尝试（使用 `UserSuspender.new(...).suspend` 作为服务对象模式）：**

5. **第五次尝试（直接设置 `active = false` 以及停权字段）：**

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2025年五月28日 14:30 UTC](https://meta.discourse.org/t/unable-to-bulk-suspend-deactivate-users-in-rails-console-on-discourse-3-5-0-beta5-dev/367571/2 "2025-05-28T14:30:25Z")

</div>

我不认为停用是用户暂停流程的一部分。在用户界面中，如果您希望已暂停并重新登录的用户重新验证其电子邮件，则需要单独按下“停用”按钮。

决定您是否需要这样做，并将其作为一项单独的操作来处理，可能会取得更好的结果。🤞

如果这对您有帮助，此主题中有一些关于批量暂停的指南：[Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349#p-582358-suspend-a-set-of-users-based-on-criteria-5)

不过，如果您尝试这样做并发现它已过时，请告知他们，他们应该能够相应地更新指南。
