# Newbie question regarding single table inheritance

**URL:** <https://www.ruby-forum.com/t/newbie-question-regarding-single-table-inheritance/119756>\
**Category:** Rails\
**Created:** [November 10, 2007, 1:28am UTC](https://www.ruby-forum.com/t/newbie-question-regarding-single-table-inheritance/119756 "2007-11-10T01:28:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 10, 2007, 1:28am UTC](https://www.ruby-forum.com/t/newbie-question-regarding-single-table-inheritance/119756/1 "2007-11-10T01:28:47Z")

</div>

In STI, how does one tell whether a subclass uses a certain attribute or  
not?  
Eric

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 10, 2007, 2:22am UTC](https://www.ruby-forum.com/t/newbie-question-regarding-single-table-inheritance/119756/2 "2007-11-10T02:22:57Z")

</div>

I don’t think there is a way to tell in your models. All attributes  
would be available to each of the subclasses. Its up to you to know  
which attributes belongs to each model.

Peer

Eric L. wrote:

> In STI, how does one tell whether a subclass uses a certain attribute or  
> not?  
> Eric

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 10, 2007, 2:38am UTC](https://www.ruby-forum.com/t/newbie-question-regarding-single-table-inheritance/119756/3 "2007-11-10T02:38:15Z")

</div>

I’m not sure but on AWDWR (page 342) I found this

“When defining the table, remember that the attributes of subclasses  
will be present only in the table rows corresponding to those  
subclasses”

So , I agree that there isn’t a way to tell your models

---

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [November 13, 2007, 10:41pm UTC](https://www.ruby-forum.com/t/newbie-question-regarding-single-table-inheritance/119756/4 "2007-11-13T22:41:57Z")

</div>

> “When defining the table, remember that the attributes of subclasses  
> will be present only in the table rows corresponding to those  
> subclasses”

Yes, but I think if I were to set attributes corresponding to a  
sibling class, Rails would still let me, assuming I haven’t put in  
place any validation that the field cannot be set.

So, it seems unless I validate that only the fields for a subclass can  
be set, the only way to tell is to ask the original developer or  
figure out based on intuition or reading the code.
