# Deleting Users in rails console

**URL:** https://meta.discourse.org/t/deleting-users-in-rails-console/141540
**Category:** Support
**Created:** [February 13, 2020, 7:26pm UTC](https://meta.discourse.org/t/deleting-users-in-rails-console/141540 "2020-02-13T19:26:34Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [October 26, 2020, 7:05pm UTC](https://meta.discourse.org/t/deleting-users-in-rails-console/141540/11 "2020-10-26T19:05:18Z")

</div>

Correct. Staff users cannot be deleted. To delete the user, you’d first have to remove their admin access.

```plaintext
u = User.find_by_username_or_email("ex@example.com")
u.admin = false
u.moderator = false
u.save
UserDestroyer.new(Discourse.system_user).destroy(u, delete_posts: false)

```

---

_[View the full topic](https://meta.discourse.org/t/deleting-users-in-rails-console/141540)._
