add Model.update! that is similar to Model.update but raises exceptions by doria...
source link: https://github.com/rails/rails/pull/42423
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Summary
Adds a method similar to Model.update
but uses update!
instead of update
on each object, so it raises on validation errors for instance
Other Information
I duplicated the tests from Model.update
and added two new tests
ails.html#contributing-to-the-rails-documentation)
It comes from a cop from rubocop that suggest using update!
but it doesn't exist on the class. I thought it would be a good idea to add it as it's better than doing update_all
in the tests for instance in some cases
a.rb:1:7: C: [Correctable] Rails/SaveBang: Use update! instead of update if the return value is not checked.
Model.update(a: 1)
^^^^^^
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK