Rails: Is there an update or update_attributes that throws exception on failure?
Just an update.. on update!
:)
update! exists since Rails 4 and update_attributes!, which was available since Rails 3, has since become just an alias for update!
.
I'm not sure why you think there is no update_attributes!
because there is. If you were reading the apidock you might have come across an issue such as they talked about here:
Why is ActiveRecord::Base#update_attributes deprecated?
Here are the docs detailing the method you want: http://apidock.com/rails/v3.2.13/ActiveRecord/Persistence/update_attributes%21
But, yes, there is an update_attributes!
that will raise an exception on validation failure. It calls save!
under the hood.