[Nitro] Q: refers_to / belongs_to vs. joins_many / many_to_many

Robert Mela rob at robmela.com
Tue Oct 16 09:23:28 EDT 2007

Poking about in og/relation/* and experimenting as I try to unravel this 
for http://robmela.com/cheatsheets/og_relations ( hopefully in a form 
that can be used in the rdocs for og or relation )

BelongsTo inherits from RefersTo but with this annotation in "enchant"

    target_class.ann!(:self)[:descendants] ||= []
    target_class.ann!(:self, :descendants) << [owner_class, foreign_key]

Something similar shows up in JoinsMany with a comment:

      # Add join class to ann(:descendants) to be able to use cascade 

      owner_class.ann!(:self)[:descendants] ||= []
      owner_class.ann!(:self, :descendants) << [tmp_join_class, owner_key]

Is there a lack of symmetry here?

   RefersTo <= BelongsTo, with descendants annotation on the *latter*
   JoinsMany <= ManyToMany, with annotation on the *former*

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20071016/ae073609/attachment.vcf 

More information about the Nitro-general mailing list