Forum: Ruby on Rails listing, restricting attributes on Single Table Inheritance

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A48fdae1d75428e49da0efee7489ce0c?d=identicon&s=25 Giridhar Tatavarty (tgiridhar)
on 2007-04-13 18:50
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

+ 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
. Are there are any examples ?

Thanks and I appreciate your Help,
This topic is locked and can not be replied to.