Giridhar Tatavarty
2007-Apr-13 16:50 UTC
listing, restricting attributes on Single Table Inheritance
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 . Are there are any examples ? Thanks and I appreciate your Help, Giri -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---