New category automatically as muted or watching for all users

How would that look like?

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

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

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

do the trick (for category 7)?

1 Like