Default values for STI subclasses


#1

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,

j