提交 1cd24e5d 编写于 作者: A Abhay Nikam 提交者: Ryuta Kamizono

Change the deprecation for Enumerating ActiveModel::Errors to Rails 6.1 instead of 6.0 (#36087)

* Change the deprecation for Enumerating ActiveModel::Errors to Rails 6.1 instead of 6.0

* Changed the deprecation message for ActiveModel::Errors methods: slice, values, keys and to_xml
上级 6f8db3d1
...@@ -229,9 +229,9 @@ def each(&block) ...@@ -229,9 +229,9 @@ def each(&block)
if block.arity == 1 if block.arity == 1
@errors.each(&block) @errors.each(&block)
else else
ActiveSupport::Deprecation.warn(<<-MSG.squish) ActiveSupport::Deprecation.warn(<<~MSG)
Enumerating ActiveModel::Errors as a hash has been deprecated. Enumerating ActiveModel::Errors as a hash has been deprecated.
In Rails 6, `errors` is an array of Error objects, In Rails 6.1, `errors` is an array of Error objects,
therefore it should be accessed by a block with a single block therefore it should be accessed by a block with a single block
parameter like this: parameter like this:
...@@ -239,9 +239,9 @@ def each(&block) ...@@ -239,9 +239,9 @@ def each(&block)
error.full_message error.full_message
end end
You are passing a block expecting 2 parameters, You are passing a block expecting two parameters,
so the old hash behavior is simulated. As this is deprecated, so the old hash behavior is simulated. As this is deprecated,
this will result in an ArgumentError in Rails 6.1. this will result in an ArgumentError in Rails 6.2.
MSG MSG
@errors. @errors.
sort { |a, b| a.attribute <=> b.attribute }. sort { |a, b| a.attribute <=> b.attribute }.
...@@ -614,7 +614,7 @@ def add_from_legacy_details_hash(details) ...@@ -614,7 +614,7 @@ def add_from_legacy_details_hash(details)
end end
def deprecation_removal_warning(method_name) def deprecation_removal_warning(method_name)
ActiveSupport::Deprecation.warn("ActiveModel::Errors##{method_name} is deprecated and will be removed in Rails 6.1") ActiveSupport::Deprecation.warn("ActiveModel::Errors##{method_name} is deprecated and will be removed in Rails 6.2")
end end
def deprecation_rename_warning(old_method_name, new_method_name) def deprecation_rename_warning(old_method_name, new_method_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册