Hi, i have read about the single inheritance stuff and the ability to use postgres views. I thougt how nice to combine, so i can still have all my stuff nicely diverted in the database. But i think i am tooo stupid for it :( asume we have the tables item [id, type, creationdate] stuff [description] the object Stuff should inherit Item so it can have a creationdate. so i thougt i set up two views: items and stuffs (plural names for rails) items (SELECT * FROM item) stuffs (SELECT * FROM items, stuff) so i could do script/generate scaffold stuffs script/generate scaffold items but app/models/Stuffs is not inheriting from app/models/Items it is still inheriting from ActiveRecord. I thougt rails will figure it out. I assume my seperation of data is just not possible with using inheritance, meaning i will always have a table or view where every subclass is mixed up in it? and do ihave to generate models just for the baseclass and define my other classes in the baseclass model? regards christian
On Apr 7, 2005 5:32 AM, Christian Schröder <spam-S5EUzP/IXfc@public.gmane.org> wrote:> Hi, > i have read about the single inheritance stuff and the ability to use postgres > views. I thougt how nice to combine, so i can still have all my stuff nicely > diverted in the database.Rails uses the Single Table Inheritance pattern. Basically, all the columns for all the subclasses go in one table, they have to allow NULLs, and you add a type column that tracks the class. Here''s a couple of articles from the wiki: http://wiki.rubyonrails.com/rails/show/SingleTableInheritance http://wiki.rubyonrails.com/rails/show/Inheritance -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org