If you need ActibeRelaton touch ActibeRelaton , you must use the update_all method. It affects several records in one transaction:
User.update_all(updated_at: Time.current) User.where(active: true).update_all(active: false)
But if you have Array entries, in this case you only use each with update
users.each { |user| update(activ: true) }
disadvantage of this case: for each user will be a separate transaction
Oleg Sobchuk
source share