# 批量编辑所有用户的电子邮件

**URL:** <https://meta.discourse.org/t/mass-edit-email-of-all-users/51687>\
**Category:** Support\
**Created:** [2016 年10 月 18 日 11:17 UTC](https://meta.discourse.org/t/mass-edit-email-of-all-users/51687 "2016-10-18T11:17:22Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

作者： ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)\
发布日期： [2017 年10 月 21 日 18:52 UTC](https://meta.discourse.org/t/mass-edit-email-of-all-users/51687/6 "2017-10-21T18:52:09Z")

</div>

> [@Falco](#):
>
> User.update\_all(“email = replace(email, ‘nonce’, ‘’)”)

I’m trying something similar, but getting a readonly error. How do I get around it? This is not a production instance, so it’s OK if I screw up.

```
User.update_all("email = replace(email, '@', '@invalid_email')")
ActiveRecord::StatementInvalid: PG::RaiseException: ERROR: Discourse: email in users is readonly
: UPDATE "users" SET email = replace(email, '@', '@invalid_email')
from /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-0.10.5/lib/patches/db/pg.rb:90:in `async_exec'

```

---

_[View the full topic](https://meta.discourse.org/t/mass-edit-email-of-all-users/51687)._
