Rails 6.1 ActiveRecord deprecates update_attributes methods
Rails 6.1 ActiveRecord deprecates update_attributes method calls. This method was renamed to update method.
Methods update_attributes
and update_attributes!
are aliases to methods update_attributes
and
update_attributes!
respectively.
The update_attributes
method
was
renamed to use update
in
this pull request
in 2013.
The PR mentions in Changelog that,
use of the update_attributes
method is renamed
to avoid its use in favor of update
method
and
it is marked for soft deprecation.
The deprecation was not handled until it was addressed in this pull request
Deprecation starting Rails 6
Use of update_attributes
and update_attributes!
will throw a warning as given below.
DEPRECATION WARNING: update_attributes! is deprecated and will be removed from Rails 6.1 (please, use update! instead)
As suggested, we need to,
- Replace
update_attributes
withupdate
- Replace
update_attributes!
withupdate!
The deprecation warning will be displayed from Rails 6 onwards. And these methods will be deprecated from Rails 6.1 version.
Reference
- Pull Request - Deprecate
update_attributes
andupdate_attributes!
- Pull request - Rename update_attributes method to update
Subscribe to Ruby in Rails
Get the latest posts delivered right to your inbox