diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-07-07 16:21:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-07 16:21:05 -0400 |
commit | 98f8f81879825a009b0c751b3178fcb687e3033a (patch) | |
tree | a374621870fb12dfc9eab3e8c67294175c081a9d /activemodel/lib/active_model/errors.rb | |
parent | 44f3ecbe5f3cb531164ed9bb14c58781281113ee (diff) | |
parent | 3650ca983c5c2ffd1a2993fa091bf504594325a7 (diff) | |
download | rails-98f8f81879825a009b0c751b3178fcb687e3033a.tar.gz rails-98f8f81879825a009b0c751b3178fcb687e3033a.tar.bz2 rails-98f8f81879825a009b0c751b3178fcb687e3033a.zip |
Merge pull request #29714 from jahfer/implement-errors-merge
Add ActiveModel::Errors#merge!
Diffstat (limited to 'activemodel/lib/active_model/errors.rb')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 942b4fa9bb..76c23df541 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -93,6 +93,18 @@ module ActiveModel @details = other.details.dup end + # Merges the errors from <tt>other</tt>. + # + # other - The ActiveModel::Errors instance. + # + # Examples + # + # person.errors.merge!(other) + def merge!(other) + @messages.merge!(other.messages) { |_, ary1, ary2| ary1 + ary2 } + @details.merge!(other.details) { |_, ary1, ary2| ary1 + ary2 } + end + # Clear the error messages. # # person.errors.full_messages # => ["name cannot be nil"] |