[Nitro] Og polymorphic question

Michael Neumann mneumann at ntecs.de
Mon Jun 20 07:19:44 EDT 2005


Am Monday 20 June 2005 13:01 schrieb George Moschovitis:
> You cannot add a 'standalone' Comment object. Is there a problem with this?
> -g.

Okay I understand that Comment cannot belong to A and B at the same time. 
But I don't understand why I have to write:

  a.comments << A::Comment.new(....)

instead of:

  a.comments << Comment.new(...)

Am I right that A::Comment is a subclass of Comment? Or maybe I'm totally 
wrong. How is it implemented?

Regards,

  Michael

> On 6/20/05, Michael Neumann <mneumann at ntecs.de> wrote:
> > Hi,
> >
> > Have a look at this piece of code:
> >
> > class A
> >   has_many Comment
> > end
> >
> > class B
> >   has_many Comment
> > end
> >
> > class Comment
> >    ....
> > end
> >
> > Now, can I simply add an object of type Comment (and not A::Comment or
> > B::Comment) to A and/or B, or not?
> >
> > Regards,
> >
> >   Michael
> > _______________________________________________
> > Nitro-general mailing list
> > Nitro-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/nitro-general



More information about the Nitro-general mailing list