# Listing, restricting attributes on Single Table Inheritance

**URL:** <https://www.ruby-forum.com/t/listing-restricting-attributes-on-single-table-inheritance/91953>\
**Category:** Rails\
**Created:** [April 13, 2007, 6:50pm UTC](https://www.ruby-forum.com/t/listing-restricting-attributes-on-single-table-inheritance/91953 "2007-04-13T18:50:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgiridhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/858c86/32.png) [@tgiridhar](https://www.ruby-forum.com/u/tgiridhar)\
**Post date:** [April 13, 2007, 6:50pm UTC](https://www.ruby-forum.com/t/listing-restricting-attributes-on-single-table-inheritance/91953/1 "2007-04-13T18:50:21Z")

</div>

Hi Gurus,

I am new to rails/ruby and have a simple question. I have single table  
inheritence implemented for different equipment. Each equipment has some  
common attributes such as equipment name, id, name of inspector etc…  
but can have totally different attributes .

like base

create table equipments  
( id autonumber |  
type varchar |  
name varchar | COMMON FOR ALL EQUIPMENT  
comment varchar |  
insepctor\_id number |  
insepction\_date date |  
Screen boolean \> only for PC, TV  
Keyboard boolean \> Only for PC  
Speaker boolean \> Only for PC, hometheater  
Remote boolean \> Only for hometheater, TV  
and so on …  
)

So the heiracrhy is pretty simple i.e 2 levels , equipment is the base  
class and particular type of equipments such as TV are derived classes

```
               Equipment - base class
        TV , hometheater, PC - derived classes of base class .

```

Here are my problems

- How do i define the attributes for each type of Equipment such as TV ,  
PC , Hometheater in the model so that i can restrict the access to other  
attributes?

- How can get i list of attributes which are applicable for that Class  
such as TV, PC or Hometheater?

I would like to write the generic forms, views ,controller for all the  
classes using the tips in  
[http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance/versions/76](http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance/versions/76)  
. Are there are any examples ?

Thanks and I appreciate your Help,  
Giri
