# 如何重新计算所有 trust\_levels？

**URL:** <https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602>\
**Category:** Support\
**Created:** [2025年六月18日 01:12 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602 "2025-06-18T01:12:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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年六月25日 18:32 UTC](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602/2 "2025-06-25T18:32:24Z")

</div>

这个方法怎么样？

> [@Modify trust level for all users](https://meta.discourse.org/t/modify-trust-level-for-all-users/103628):
>
> Here’s an example of a [bulk operation](https://meta.discourse.org/t/administrative-bulk-operations/118349) to set the trust level to 2 for all users currently at trust level 0 or 1: This is slow, but ensures that locked trust levels aren’t changed. But it may be preferred especially when you have fewer than 1000 users User.where(trust\_level: [0, 1]).find\_each do |user| user.change\_trust\_level!(TrustLevel[2]) end If there were more than 1000 users, I would have used this instead, but this would not respect locked trust levels. DB.exec("UPDATE users SET trus…

不。也许不是你想要的。🤔

---

_[View the full topic](https://meta.discourse.org/t/how-to-recalculate-all-trust-levels/370602)._
