-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:
EDIT: I'm beginning to suspect that this "bug" might be a misunderstanding on my part. That these cyclic references are indeed supposed to be embedded in nature. If so, most of what I've written above is invalid and I restrict myself to suggesting the mentioned syntax for referential cyclic relationships. // END EDIT
Using validate uniqueness on a document with cyclic references fails, because the validator threats the document as embedded (uniqueness.rb:34) and will try to access the parent (itself). See this link for more info (if needed): http://pastie.org/1485270
Furthermore, maybe it would be better to use reference instead of embedded for cyclic relationships.
I feel it make more sense for cyclic relationships to be referred to as references. After all there is no embedding taking place, there is an actual reference/id/foreignkey. I.e.
recursively_references_many
references_many :child_roles, :class_name => "Role", :cyclic => true
referenced_in :parent_role, :class_name => "Role", :cyclic => true
recursively_references_one
references_one :child_role, :class_name => "Role", :cyclic => true
referenced_in :parent_role, :class_name => "Role", :cyclic => true
As a side effect the above mentioned problem would (probably) go away, because the relation would correctly be identified as referential.
On a side note; there has been much progress lately. Nice to see! I also feel that I start to understand more about Rails and Mongoid so hopefully I can contribute some patches in the future.