Forum: Ruby on Rails Default values for STI subclasses

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9504085aec1ea24cbf5e6781fc10cff0?d=identicon&s=25 Jdkunesh (Guest)
on 2006-12-31 05: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,

j
This topic is locked and can not be replied to.