module ActiveRecord::Inheritance::ClassMethods

Public Instance Methods

new(attributes = nil, options = {}, &block) click to toggle source
Calls superclass method
# 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