Update multiple records simultaneously with ActiveRecord in Rails using one query?
问题 Let's suppose I have a table called 'user_products' and a corresponding model called UserProduct in my Rails application. I also have a field called 'is_temporary' in my table. Now suppose I want to run a query like this but using the ActiveRecord abstraction layer: UPDATE user_products SET is_temporary = false WHERE user_id = 12345; Is there a way I can do this using ActiveRecord? Maybe something along the lines of UserProduct.find_by_user_id(12345).update_attributes(:is_temporary => false)