diff options
author | lulalala <mark@goodlife.tw> | 2018-04-02 22:40:09 +0800 |
---|---|---|
committer | lulalala <mark@goodlife.tw> | 2019-03-31 22:59:12 +0800 |
commit | 86b4aa1175b23deca15981fbc19cf7f02b13b25d (patch) | |
tree | 870d37d6ef7baf6efe727c127c45a63d3e47a06d /activemodel/lib/active_model | |
parent | 655036b09a99daaa5b5f77777f23fc13829919b0 (diff) | |
download | rails-86b4aa1175b23deca15981fbc19cf7f02b13b25d.tar.gz rails-86b4aa1175b23deca15981fbc19cf7f02b13b25d.tar.bz2 rails-86b4aa1175b23deca15981fbc19cf7f02b13b25d.zip |
Backward compatibility for errors.collect/select etc.
All enumerable methods must go through the `each` so it retain old hash behavior.
Revert this after Rails 6.1 in order to speed up enumerable methods.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 9800d9305e..98e16ea455 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -64,7 +64,7 @@ module ActiveModel include Enumerable extend Forwardable - def_delegators :@errors, :size, :clear, :blank?, :empty?, *(Enumerable.instance_methods(false) - [:to_a, :include?]) + def_delegators :@errors, :size, :clear, :blank?, :empty? LEGACY_ATTRIBUTES = [:messages, :details].freeze @@ -309,7 +309,7 @@ module ActiveModel end def group_by_attribute - group_by(&:attribute) + @errors.group_by(&:attribute) end # Adds +message+ to the error messages and used validator type to +details+ on +attribute+. |