1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Support nested AR::Models

This commit is contained in:
Jon Leighton 2011-12-24 10:23:19 +00:00
parent 15fbf5b58b
commit 0e3e34f0eb
3 changed files with 13 additions and 1 deletions

View file

@ -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 += '_'

View file

@ -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

View file

@ -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