aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-09-17 16:15:04 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-09-17 16:15:04 -0700
commit7701c6f1c012abb09cd61d3092fbb40fc77aeb6d (patch)
tree55a5ebfc834a776a2907ebf61d72aa015e713052 /activerecord
parent636624fbf2952e1fd46b95c9199048b3d6647870 (diff)
downloadrails-7701c6f1c012abb09cd61d3092fbb40fc77aeb6d.tar.gz
rails-7701c6f1c012abb09cd61d3092fbb40fc77aeb6d.tar.bz2
rails-7701c6f1c012abb09cd61d3092fbb40fc77aeb6d.zip
Collapse nested conditional
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb28
1 files changed, 13 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index afa4185c60..1adab2e832 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -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