Rails 6 adds touch_all method to ActiveRecord::Relation by Romil Mehta — 28 August 2019 https://blog.saeloun.com/2019/08/27/rails-6-touch_all-method.html Comments Earlier also we could have done that without N+1 queries in this way: Product.where(“price >= ?”, 100).update_all(created_at: Time.now) Also Product.where(“price >= ?”, 100).touch_all would generate the same SQL query as the way. Please correct me if I’m wrong or missing something. abhi4nfp — 29 August 2019 The implementation of touch_all is here https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation.rb#L524 abhi4nfp — 29 August 2019 Post a comment You can use basic HTML markup (e.g. <a>) or Markdown. Authenticate with GitHub As you are not logged in, you will bedirected via GitHub to signup or sign in
Comments
Earlier also we could have done that without N+1 queries in this way:
Product.where(“price >= ?”, 100).update_all(created_at: Time.now)
Also Product.where(“price >= ?”, 100).touch_all would generate the same SQL query as the way.
Please correct me if I’m wrong or missing something.
The implementation of touch_all is here https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation.rb#L524
Post a comment