25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/active_record/mass_assignment_security/inheritance.rb', line 25
def new(attributes = nil, options = {}, &block)
if abstract_class? || self == Base
raise NotImplementedError, "#{self} is an abstract class and cannot be instantiated."
end
if has_attribute?(inheritance_column)
subclass = subclass_from_attributes(attributes)
if respond_to?(:column_defaults) && subclass.nil? && base_class == self
subclass = subclass_from_attributes(column_defaults)
end
end
if subclass && subclass != self
subclass.new(attributes, options, &block)
else
super
end
end
|