Before moving forward, we need to understand what the touch method does. touch is used to
update the updated_at timestamp by defaulting to the current time. It also takes custom time or different columns as parameters.
Rails 6 has added touch_all on ActiveRecord::Relation
to touch multiple records in one go. Before Rails 6, we needed to iterate all records using an iterator to achieve this result.
Let’s take an example in which we call touch_all on all user records.
touch_all returns count of the records on which it is called.
touch_all also takes a custom time or different columns as parameters.