diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-03-08 11:55:31 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-03-08 11:59:45 -0300 |
commit | ad624345e54bd20802de67b2b5c9ef29ecf5d5f4 (patch) | |
tree | 8831922f30aed619f3f488600b3ebe7b4696ba56 | |
parent | 74d24ea1fe4f83bb7ae7c7b5aa1af82a1592c841 (diff) | |
download | rails-ad624345e54bd20802de67b2b5c9ef29ecf5d5f4.tar.gz rails-ad624345e54bd20802de67b2b5c9ef29ecf5d5f4.tar.bz2 rails-ad624345e54bd20802de67b2b5c9ef29ecf5d5f4.zip |
Avoid short-circuit return
-rw-r--r-- | activerecord/lib/active_record/inheritance.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb index faef5a9527..f54865c86e 100644 --- a/activerecord/lib/active_record/inheritance.rb +++ b/activerecord/lib/active_record/inheritance.rb @@ -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 |