1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated support delete errors from ActiveModel::Errors#messages

This commit is contained in:
Rafael Mendonça França 2021-11-16 16:50:09 +00:00
parent b2db6f390c
commit bab78b5d54
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
4 changed files with 6 additions and 15 deletions

View file

@ -1,3 +1,7 @@
* Remove deprecated support `delete` errors from `ActiveModel::Errors#messages`.
*Rafael Mendonça França*
* Remove deprecated support `clear` errors from `ActiveModel::Errors#messages`. * Remove deprecated support `clear` errors from `ActiveModel::Errors#messages`.
*Rafael Mendonça França* *Rafael Mendonça França*

View file

@ -511,12 +511,6 @@ module ActiveModel
__setobj__ prepare_content __setobj__ prepare_content
end end
def delete(attribute)
ActiveSupport::Deprecation.warn("Calling `delete` to an ActiveModel::Errors messages hash is deprecated. Please call `ActiveModel::Errors#delete` instead.")
@errors.delete(attribute)
end
private private
def prepare_content def prepare_content
content = @errors.to_hash content = @errors.to_hash

View file

@ -605,15 +605,6 @@ class ErrorsTest < ActiveModel::TestCase
) )
end end
test "messages delete (deprecated)" do
person = Person.new
person.validate!
assert_equal 1, person.errors.count
assert_deprecated { person.errors.messages.delete(:name) }
assert_empty person.errors
end
test "group_by_attribute" do test "group_by_attribute" do
person = Person.new person = Person.new
error = person.errors.add(:name, :invalid, message: "is bad") error = person.errors.add(:name, :invalid, message: "is bad")

View file

@ -138,6 +138,8 @@ Please refer to the [Changelog][active-model] for detailed changes.
* Remove deprecated support `clear` errors from `ActiveModel::Errors#messages`. * Remove deprecated support `clear` errors from `ActiveModel::Errors#messages`.
* Remove deprecated support `delete` errors from `ActiveModel::Errors#messages`.
### Deprecations ### Deprecations
### Notable changes ### Notable changes