Forum: Ruby on Rails acts_as_tree circular reference

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Iphan I. (Guest)
on 2006-03-08 15:21
my application is using acts_as_tree to create a directed graph.

Everyone would work fine, except that nothing prevents the user to
create a circular reference:

>> item.parent=child
=> true
>> child.parent=item
=> true

I checked in the database, and there it is: an item that has as parent
its own child!

item.parent_id = child_id

I know I could add code to prevent this from happening, but shouldn't
that be the job of acts_as_tree ?
This topic is locked and can not be replied to.