mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
6f8db3d1f3
commit
1cd24e5d00
1 changed files with 5 additions and 5 deletions
|
@ -229,9 +229,9 @@ module ActiveModel
|
|||
if block.arity == 1
|
||||
@errors.each(&block)
|
||||
else
|
||||
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
||||
ActiveSupport::Deprecation.warn(<<~MSG)
|
||||
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
|
||||
parameter like this:
|
||||
|
||||
|
@ -239,9 +239,9 @@ module ActiveModel
|
|||
error.full_message
|
||||
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,
|
||||
this will result in an ArgumentError in Rails 6.1.
|
||||
this will result in an ArgumentError in Rails 6.2.
|
||||
MSG
|
||||
@errors.
|
||||
sort { |a, b| a.attribute <=> b.attribute }.
|
||||
|
@ -614,7 +614,7 @@ module ActiveModel
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def deprecation_rename_warning(old_method_name, new_method_name)
|
||||
|
|
Loading…
Reference in a new issue