aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-23 13:09:53 -0400
committerGitHub <noreply@github.com>2019-07-23 13:09:53 -0400
commitd8bda0170210101df448313dcbf4ddd118e90327 (patch)
tree8b560cc8873d684e9412692583be7546cfe2e771 /activemodel/lib
parent0354b0d6c695bcbaa2750f47fa568dd3b69c59a3 (diff)
parentff0204bc7f5b33a04cfe4f053e3f24a65f0faff5 (diff)
downloadrails-d8bda0170210101df448313dcbf4ddd118e90327.tar.gz
rails-d8bda0170210101df448313dcbf4ddd118e90327.tar.bz2
rails-d8bda0170210101df448313dcbf4ddd118e90327.zip
Merge pull request #36738 from Edouard-chin/ec-errors-to_hash-string
Modify behaviour of `AM::Errors#to_h`:
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/errors.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index e7405fb586..480f24183a 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -304,9 +304,13 @@ module ActiveModel
end
def to_h
- deprecation_rename_warning(:to_h, :to_hash)
+ ActiveSupport::Deprecation.warn(<<~EOM)
+ ActiveModel::Errors#to_h is deprecated and will be removed in Rails 6.2
+ Please use `ActiveModel::Errors.to_hash` instead. The values in the hash
+ returned by `ActiveModel::Erors.to_hash` is an array of error messages.
+ EOM
- to_hash
+ to_hash.transform_values { |values| values.last }
end
def messages