Forum: Ruby on Rails Fixture files for inserting tree like behavior doesn't work

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.
Dirk Breuer (Guest)
on 2006-01-05 15:54
Hi folks around, hope you could help me with my problem.

I have a porblem while testing my Acts_as_Tree behavior with fixtures.
Because all data in the fixture file will be commited at the end the
entries I want to map my tree like structure to will not be present at
this point. Due to this I get a foreign key constraints fails from the
database. Is there any way to solve this problem?

Here is a short example of the problem:

# Fixture file for testing Acts_as_Tree behavior
  id:        1
  name:      root
  id:        2
  name:      left_node
  parent_id: 1
  id:        3
  name:      right_node
  parent_id: 1
Tom M. (Guest)
on 2006-01-05 18:44
(Received via mailing list)
It has nothing to do with when the commit happens.

It has everything to do with the fact that they're
loaded in alphabetical order.

-- Tom M.
This topic is locked and can not be replied to.