Forum: Ruby on Rails Default values for STI subclasses

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.
Jdkunesh (Guest)
on 2006-12-31 06:15
(Received via mailing list)
Hey everybody-

I'm working on an application for creating simple HTML prototypes. In
it, I have objects Page, Appearance and Section. Pages have Sections
through Appearance, and sections are stored in single table inheritance
table, with subclasses Header, Body and Footer.

My problem is a simple one, I think?

When I set up a new page, I want to create it with a Header, Body, and
Footer already associated. On page.create, I create and append a new
Header, Body and Footer object to @page.appearances. Without hardcoding
these values, where could I set them up?

It seems like I should be able to do it in Header/Body/Footer def
initialize() by checking to see if there is a value for each of the
properties, but it bombs horribly despite my best efforts. Can anyone
shed some light on this for an OOP n00b?

thanks, and happy holidays,

This topic is locked and can not be replied to.