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 .
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,