diff options
author | Jeffrey Guenther <guenther.jeffrey@gmail.com> | 2017-12-14 19:03:28 -0800 |
---|---|---|
committer | Jeffrey Guenther <guenther.jeffrey@gmail.com> | 2017-12-14 19:03:28 -0800 |
commit | 1c5358e4729ce48b0e597d0b39d22f3b1c42f6fc (patch) | |
tree | ea060a71e57ec1e6366a33f7e40be14ea2f0d64b /activerecord/lib/active_record/inheritance.rb | |
parent | ab2a95db8088b7607017671b82e396bcd9e80332 (diff) | |
parent | cc0d272c8c37c197a7e68633e5f082eccb2e3737 (diff) | |
download | rails-1c5358e4729ce48b0e597d0b39d22f3b1c42f6fc.tar.gz rails-1c5358e4729ce48b0e597d0b39d22f3b1c42f6fc.tar.bz2 rails-1c5358e4729ce48b0e597d0b39d22f3b1c42f6fc.zip |
Merge branch 'master' into activestorage-guide
Diffstat (limited to 'activerecord/lib/active_record/inheritance.rb')
-rw-r--r-- | activerecord/lib/active_record/inheritance.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb index 0715c11473..f3fe610c09 100644 --- a/activerecord/lib/active_record/inheritance.rb +++ b/activerecord/lib/active_record/inheritance.rb @@ -47,14 +47,13 @@ module ActiveRecord # Determines if one of the attributes passed in is the inheritance column, # and if the inheritance column is attr accessible, it initializes an # instance of the given subclass instead of the base class. - def new(*args, &block) + def new(attributes = nil, &block) if abstract_class? || self == Base raise NotImplementedError, "#{self} is an abstract class and cannot be instantiated." end - attrs = args.first if has_attribute?(inheritance_column) - subclass = subclass_from_attributes(attrs) + subclass = subclass_from_attributes(attributes) if subclass.nil? && base_class == self subclass = subclass_from_attributes(column_defaults) @@ -62,7 +61,7 @@ module ActiveRecord end if subclass && subclass != self - subclass.new(*args, &block) + subclass.new(attributes, &block) else super end |