Check If ActiveRecord Update Fails
There are two ways to update an ActiveRecord
instance (not to mention assign_attributes
, update_attribute
, etc.).
You can call update
and update!
. If the updates would make the record invalid based on the model's validations, then the update will fail.
You can tell if update
failed because it will return false
(instead of true
).
The update!
version will raise an ActiveRecord::ActiveRecordError
exception if the update fails.
Last updated