diff options
author | lulalala <mark@goodlife.tw> | 2019-03-17 15:57:00 +0800 |
---|---|---|
committer | lulalala <mark@goodlife.tw> | 2019-03-31 22:59:13 +0800 |
commit | aaa0c3279745e3405bc3279924e41cb641e1af8e (patch) | |
tree | cfa563eee1a914dc7f85705e7142d1f236d1880c /activemodel/lib | |
parent | f7f42a2d0e7154f30d3f1f6cbedf14fc2c3f5b52 (diff) | |
download | rails-aaa0c3279745e3405bc3279924e41cb641e1af8e.tar.gz rails-aaa0c3279745e3405bc3279924e41cb641e1af8e.tar.bz2 rails-aaa0c3279745e3405bc3279924e41cb641e1af8e.zip |
Set default array to details
maintaining behavior errors.details[:foo].any?
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index ac19b4625e..a9af426fb1 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -318,7 +318,7 @@ module ActiveModel group_by_attribute.each do |attribute, errors| hash[attribute] = errors.map(&:detail) end - hash + DeprecationHandlingDetailsHash.new(hash) end def group_by_attribute @@ -672,6 +672,14 @@ module ActiveModel end end + class DeprecationHandlingDetailsHash < SimpleDelegator + def initialize(details) + details.default = [] + details.freeze + super(details) + end + end + # Raised when a validation cannot be corrected by end users and are considered # exceptional. # |