aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb2
-rw-r--r--activerecord/test/cases/inheritance_test.rb14
2 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index aed4eff565..9204295d8c 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -890,7 +890,7 @@ module ActiveRecord #:nodoc:
end
def find_sti_class(type_name)
- if type_name.nil? || !columns_hash.include?(inheritance_column)
+ if type_name.blank? || !columns_hash.include?(inheritance_column)
self
else
begin
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb
index 8c09fc4d59..31679b2efe 100644
--- a/activerecord/test/cases/inheritance_test.rb
+++ b/activerecord/test/cases/inheritance_test.rb
@@ -14,6 +14,20 @@ class InheritanceTest < ActiveRecord::TestCase
ActiveRecord::Base.store_full_sti_class = old
end
+ def test_class_with_blank_sti_name
+ company = Company.find(:first)
+ company = company.clone
+ company.extend(Module.new {
+ def read_attribute(name)
+ return ' ' if name == 'type'
+ super
+ end
+ })
+ company.save!
+ company = Company.find(:all).find { |x| x.id == company.id }
+ assert_equal ' ', company.type
+ end
+
def test_class_without_store_full_sti_class_returns_demodulized_name
old = ActiveRecord::Base.store_full_sti_class
ActiveRecord::Base.store_full_sti_class = false