# Deleting Users in rails console

**URL:** <https://meta.discourse.org/t/deleting-users-in-rails-console/141540>\
**Category:** Product 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:** 9

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [September 21, 2020, 3:02pm UTC](https://meta.discourse.org/t/deleting-users-in-rails-console/141540/9 "2020-09-21T15:02:36Z")

</div>

Hi, no one has a solution? It seems to happen only when trying to delete some accounts but not others, and I can’t figure out why.

Exemple of my loop running:

```plaintext
2821 : Gurpreet
2969 : GUY26
3012 : dboy3587
3015 : devilsports
3020 : jimyyyy
3029 : vdubgrub
3071 : Frank1
3126 : volgano
3172 : dawei
3307 : almolatham
3320 : embsoft
3352 : auto
3379 : sulemaninc
3447 : Baton
3463 : galvin
3465 : autopartchina
3497 : tracker
Discourse::InvalidAccess: can_delete_user? failed
from /var/www/discourse/lib/guardian/ensure_magic.rb:11:in `method_missing'

```

All users have been deleted, but not the last one. If I skip this one, it will delete next users until it can’t delete another user for an unidentified reason.

edit: I had to edit these settings:  
**delete all post max**  
**delete\_user\_max\_post\_age**  
👍🏿

---

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