diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 08f3451254..adf85c6436 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -291,7 +291,7 @@ module ActiveRecord base = base_class if self == base # Nested classes are prefixed with singular parent table name. - if parent < ActiveRecord::Base && !parent.abstract_class? + if parent < ActiveRecord::Model && !parent.abstract_class? contained = parent.table_name contained = contained.singularize if parent.pluralize_table_names contained += '_' diff --git a/activerecord/test/cases/inclusion_test.rb b/activerecord/test/cases/inclusion_test.rb index 189e537bd6..4b3320cf04 100644 --- a/activerecord/test/cases/inclusion_test.rb +++ b/activerecord/test/cases/inclusion_test.rb @@ -29,6 +29,10 @@ class BasicInclusionModelTest < ActiveRecord::TestCase assert_equal "Bob", Teapot.where(:id => [t]).first.name assert_equal "Bob", Teapot.where(:id => t).first.name end + + def test_nested_model + assert_equal "ceiling_teapots", Ceiling::Teapot.table_name + end end class InclusionUnitTest < ActiveRecord::TestCase diff --git a/activerecord/test/models/teapot.rb b/activerecord/test/models/teapot.rb index 00e066a1b3..ff18b6a96d 100644 --- a/activerecord/test/models/teapot.rb +++ b/activerecord/test/models/teapot.rb @@ -22,3 +22,11 @@ class CoolTeapot < OMFGIMATEAPOT include ActiveRecord::Model self.table_name = "teapots" end + +class Ceiling + include ActiveRecord::Model + + class Teapot + include ActiveRecord::Model + end +end