From e885b18fe9d20746fd0e5165815119bd2836cd60 Mon Sep 17 00:00:00 2001 From: Angelo Capilleri Date: Tue, 15 May 2012 21:32:10 +0200 Subject: add backport for the pull request #6324 --- activemodel/lib/active_model/validations.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activemodel') diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index b48e910408..18cd53e130 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -168,7 +168,15 @@ module ActiveModel # Clean the +Errors+ object if instance is duped def initialize_dup(other) # :nodoc: @errors = nil - super + end + + # Backport dup from 1.9 so that #initialize_dup gets called + unless Object.respond_to?(:initialize_dup) + def dup # :nodoc: + copy = super + copy.initialize_dup(self) + copy + end end # Returns the +Errors+ object that holds all information about attribute error messages. -- cgit v1.2.3