I want to create models with child models.
As an example, one model Event and submodels OneTimeEvent and
RecurringEvent.
How should I do this?
One possibility would be to use
class Event < Activerecord
class OneTimeEvent < Event
class RecurringEvent < Event
Does this work correctly?
And how/where should I store the special information each type has
(i.e. day_of_month for recurring)?
At the bottom there, there is an unanswered question:
Q. What about model attributes when using STI?
eg. I have Page, Article and Comment all inheriting from ContentItem.
Only comment uses the commentable_id column.
Some of these models will have more attributes than others. How do I
make sure the more specific atrributes are hidden or disabled from the
parent model, while enabling those attributes for select models using
those attributes?
That`s also interesting me.
Can you tell me more about this?
At the bottom there, there is an unanswered question:
Q. What about model attributes when using STI?
eg. I have Page, Article and Comment all inheriting from ContentItem.
Only comment uses the commentable_id column.
Some of these models will have more attributes than others. How do I
make sure the more specific atrributes are hidden or disabled from the
parent model, while enabling those attributes for select models using
those attributes?
Nothing builtin for doing this. If you have a lot of attributes like
this then it can be a sign that STI isn't the right tool for the job.