update multiple rows in Rails 3.2

find returns an array, so you cannot use update_all.

To solve the problem, I think you can use where, which returns an ActiveRecord::Relation, so the update_all should work:

User.where(:id =>[23,45,68,123]).update_all(:is_active => true)

http://apidock.com/rails/ActiveRecord/Relation/update_all

I hope it helps…

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)