提交 0e3e34f0 编写于 作者: J Jon Leighton

Support nested AR::Models

上级 15fbf5b5
......@@ -291,7 +291,7 @@ def compute_table_name
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 += '_'
......
......@@ -29,6 +29,10 @@ def test_predicate_builder
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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册