mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Avoid short-circuit return
This commit is contained in:
parent
74d24ea1fe
commit
ad624345e5
1 changed files with 9 additions and 5 deletions
|
@ -170,12 +170,16 @@ module ActiveRecord
|
|||
# this will ignore the inheritance column and return nil
|
||||
def subclass_from_attrs(attrs)
|
||||
subclass_name = attrs.with_indifferent_access[inheritance_column]
|
||||
return if subclass_name.blank? || subclass_name == self.name
|
||||
subclass = subclass_name.safe_constantize
|
||||
unless subclasses.include?(subclass)
|
||||
raise ActiveRecord::SubclassNotFound.new("Invalid single-table inheritance type: #{subclass_name} is not a subclass of #{name}")
|
||||
|
||||
if subclass_name.present? && subclass_name != self.name
|
||||
subclass = subclass_name.safe_constantize
|
||||
|
||||
unless subclasses.include?(subclass)
|
||||
raise ActiveRecord::SubclassNotFound.new("Invalid single-table inheritance type: #{subclass_name} is not a subclass of #{name}")
|
||||
end
|
||||
|
||||
subclass
|
||||
end
|
||||
subclass
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue