Model-update_attribute & update_attributes

Bookmark and Share

Presently it seems lot of people are confusing between the functionality of update_attribute and update_attributes. The purpose of these functions can be understood from their name itself. the first one update_attribute would update a single attribute of the model

Its used as

and the later update_attributes updates a whole set of values in the model

Now the important differentiator of these two functions is that the first function update_attribute updates an attribute without running any of the validations mentioned..

So keep that in mind when you are using the update_attribute function, else at times you will find values you didn’t expect to be entered into the database found in them.

Happy Coding

Read More