# Bulk suspend users based on criteria

**URL:** <https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804>\
**Category:** Product Support\
**Created:** [27.Декабрь.2017 08:06:27 UTC](https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804 "2017-12-27T08:06:27Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)\
**Post date:** [01.Январь.2018 16:12:25 UTC](https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804/10 "2018-01-01T16:12:25Z")

</div>

There is no `group_id` column on `users`. There is instead a separate `group_users` table and `groups` table. I usually connect to pg directly to list all the tables and poke around, but you can list all the tables in the rails console with `ActiveRecord::Base.connection.tables`

You will need do do a join like:

```plaintext
users = User.joins(:group_users).where.not(group_users: {group_id: 41}).where(id: 1..Float::INFINITY, admin: false)

```

---

_[View the full topic](https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804)._
