Is there a shorter way for this in Rails 3?
user.update_column(:attribute1, value1)
user.update_column(:attribute2, value2)
user.update_column(:attribute3, value3)
user.update_column(:attribute4, value4)
I tried update_columns
but it's only available in Rails 4.
Thanks for any help.
another approach you can take which accomplishes the same thing is this:
NOTE: You don't have to use the validate false. However, the #update_column method does skip validations and callbacks. So if that is what you are looking for, use the validate false.
If you need speed you can also call execute directly on AR connection. I used something like this to import large amount of data.
Note that validations and callbacks will not be run.
Here's a workaround for Rails 3.x: