# New category automatically as muted or watching for all users

**URL:** https://meta.discourse.org/t/new-category-automatically-as-muted-or-watching-for-all-users/51654
**Category:** Support
**Created:** [17.Октябрь.2016 19:36:46 UTC](https://meta.discourse.org/t/new-category-automatically-as-muted-or-watching-for-all-users/51654 "2016-10-17T19:36:46Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [09.Ноябрь.2016 12:40:22 UTC](https://meta.discourse.org/t/new-category-automatically-as-muted-or-watching-for-all-users/51654/3 "2016-11-09T12:40:22Z")

</div>

How would that look like?

I’d assume it’s a loop over all users where for each user, something like

```ruby
CategoryUser.create!(user_id: user.id, <INSERT HERE>, CategoryUser.notification_levels[:muted])

```

is run – but my Ruby skills are quite lacking, and I assume this would crash if the user already had an entry here.

* * *

`CategoryUser.batch_set` is also looking promising…

* * *

Would

```ruby
User.all.each do |user| CategoryUser.batch_set(user, :muted, [7]) end

```

do the trick (for category 7)?

---

_[View the full topic](https://meta.discourse.org/t/new-category-automatically-as-muted-or-watching-for-all-users/51654)._
