aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorPaweł Kondzior <pawel@kondzior.com>2012-01-16 23:07:15 -0800
committerPaweł Kondzior <pawel@kondzior.com>2012-01-16 23:22:51 -0800
commit5313eab6954aff1235aca9126d662aac5b6c300d (patch)
treeabbdea13159ea0f1d4e5e7c2cc949678875ed694 /activemodel/lib
parent21afd9b96d70d1e2b1cffdfb60f7ec64ab240472 (diff)
downloadrails-5313eab6954aff1235aca9126d662aac5b6c300d.tar.gz
rails-5313eab6954aff1235aca9126d662aac5b6c300d.tar.bz2
rails-5313eab6954aff1235aca9126d662aac5b6c300d.zip
Fix ActiveModel::Errors#dup
Since ActiveModel::Errors instance keeps all error messages as hash we should duplicate this object as well. Previously ActiveModel::Errors was a subclass of ActiveSupport::OrderedHash, which results in different behavior on `dup`, this may result in regression for people relying on it.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/errors.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index c6535082d3..4a0ad618bc 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -78,6 +78,11 @@ module ActiveModel
@messages = ActiveSupport::OrderedHash.new
end
+ def initialize_dup(other)
+ @messages = other.messages.dup
+ super
+ end
+
# Clear the messages
def clear
messages.clear