# Reset default categories watching setting

**URL:** https://meta.discourse.org/t/reset-default-categories-watching-setting/244930
**Category:** Support
**Created:** [November 8, 2022, 10:15pm UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930 "2022-11-08T22:15:21Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![mononym](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mononym/32/566879_2.png) [@mononym](https://meta.discourse.org/u/mononym)
#### Post date: [April 1, 2025, 8:37am UTC](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930/8 "2025-04-01T08:37:21Z")

</div>

I think the bellow steps solved the issue !

In the site settings I set the category (31) to be watched by default, retroactively.  
Check:

```ruby
CategoryUser.where(category_id: 31).pluck(:user_id, :notification_level)

```

Most users have a `notification_level` of `3` for my category `31`. 👍

Now there are two things in the way for this change to have a 100% effect:

1. The user’s global email preferences.
2. The user’s notification preferences for each topic in the category (31).

* * *

⚠ The following lines will modify personal settings of your users. Don’t get into a fight.

First, in order to “reactivate” the user’s emails, one has to set the users `email_level` to 1 (i.e. “when away”) or 2 (“always”):

```ruby
UserOption.update_all(email_level: 1)

```

Check:

```ruby
UserOption.group(:email_level).count

```

I get something like `=> {1=>X}` with `X` being the number of users.

Second, the topic `notification_level` has priority over the category `notification_level` (which was modified in the site settings). The easiest way is to get the topic preferences out of the way. To do so, one simply deletes the entries topic by topic:

```ruby
TopicUser.where(topic_id: <topic_id_nr>).destroy_all

```

Check:

```ruby
TopicUser.where(topic_id: <topic_id_nr>).exists?

```

Getting something like `=> []` which means no user has topic preferences and the category `notification_level` will be the default for all users.

* * *

N.B.: Somehow, some users still had no notification preferences for the category (31) set (i.e. no entry in the `category_user` table). To make sure their `notification_level` is set, one has to create an entry with the value for `notification_level`:

```ruby
User.find_each do |user|
  unless CategoryUser.exists?(user_id: user.id, category_id: 31)
    CategoryUser.create!(user_id: user.id, category_id: 31, notification_level: 3)
  end
end

```

Check:

```ruby
CategoryUser.where(category_id: 31).pluck(:id, :notification_level)

```

---

_[View the full topic](https://meta.discourse.org/t/reset-default-categories-watching-setting/244930)._
