Hello, 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)? Thanks Jonas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You''re probably looking for an STI (single table inheritance) implementation. http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance is a starting place. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the link. 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? Thanks Jonas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey guys, I got another question: if I want a row to be part of both subclasses, is this possible? And if not, how can I disable the attributes of one class (so I can have 2 different interfaces)? Thanks, Jonas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 20 Sep 2008, at 12:51, Jonas Schneider wrote:> > Thanks for the link. > > 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. Fred> > > That`s also interesting me. > Can you tell me more about this? > > Thanks > Jonas > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---