mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Collapse nested conditional
This commit is contained in:
@@ -1654,22 +1654,20 @@ module ActiveRecord #:nodoc:
|
||||
if subclass_name.empty?
|
||||
allocate
|
||||
|
||||
else
|
||||
# Ignore type if no column is present since it was probably
|
||||
# pulled in from a sloppy join.
|
||||
unless columns_hash.include?(inheritance_column)
|
||||
allocate
|
||||
# Ignore type if no column is present since it was probably
|
||||
# pulled in from a sloppy join.
|
||||
elsif !columns_hash.include?(inheritance_column)
|
||||
allocate
|
||||
|
||||
else
|
||||
begin
|
||||
compute_type(subclass_name).allocate
|
||||
rescue NameError
|
||||
raise SubclassNotFound,
|
||||
"The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " +
|
||||
"This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
|
||||
"Please rename this column if you didn't intend it to be used for storing the inheritance class " +
|
||||
"or overwrite #{self.to_s}.inheritance_column to use another column for that information."
|
||||
end
|
||||
else
|
||||
begin
|
||||
compute_type(subclass_name).allocate
|
||||
rescue NameError
|
||||
raise SubclassNotFound,
|
||||
"The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " +
|
||||
"This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
|
||||
"Please rename this column if you didn't intend it to be used for storing the inheritance class " +
|
||||
"or overwrite #{self.to_s}.inheritance_column to use another column for that information."
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user