Skip to content

Commit 8470fdb

Browse files
committed
Merge pull request rails#6329 from acapilleri/backport_dup_validation_3_2
Backport dup validation 3 2
2 parents 2dfa8b5 + e885b18 commit 8470fdb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

activemodel/lib/active_model/validations.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,15 @@ def inherited(base)
168168
# Clean the +Errors+ object if instance is duped
169169
def initialize_dup(other) # :nodoc:
170170
@errors = nil
171-
super
171+
end
172+
173+
# Backport dup from 1.9 so that #initialize_dup gets called
174+
unless Object.respond_to?(:initialize_dup)
175+
def dup # :nodoc:
176+
copy = super
177+
copy.initialize_dup(self)
178+
copy
179+
end
172180
end
173181

174182
# Returns the +Errors+ object that holds all information about attribute error messages.

0 commit comments

Comments
 (0)