Ruby on Rails Friday, January 27, 2017

What do you think about adding update_each and update_each! to ActiveRecord?

Basically it would make it easier to switch from update_all but triggering the callbacks (and could be later optimized, where `each { |m| m.update(...) }` is very difficult to optimize from the Rails-side.

A simple implementation could be:

class ActiveRecord::Base
  def self.update_each(updates)
    find_each { |model| model.update(updates) }

  def self.update_each!(updates)
    find_each { |model| model.update!(updates) }


You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment