Trading buttons: Buy, Sell, Exchange

Any destructive actions run on the console are a little scary. Make sure you take a backup before running them.

A CategoryUser record describes a user’s notification level for a category. A notification_level of 0 means that the category is muted for the user. You can find more information here: How do I set category tracking level defaults historically.

Deleting all CategoryUser records for a given category_id with a notification_level of 0, will remove that category from the muted list for all users on your site.

When I run a command like this, I usually add an extra step that I didn’t post above. Instead of running

CategoryUser.where(category_id: c.id, notification_level: 0).destroy_all

in a single step, I’ll assign the records to a variable so that I can double check that I’m dealing with the correct data. Something like this:

# Get the category and assign it to a variable
c = Category.find_by(name: "<your category name>")

# Assign the category_users to a variable and examine the data. Make sure the records have the
# correct category_id etc.
muted_category_users = CategoryUser.where(category_id: c.id, notification_level: 0)

# When you are certain that the data is correct run
muted_category_users.destroy_all
3 Likes