Fixture files for inserting tree like behavior doesn't work


#1

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

Root:
id: 1
name: root
Left_Node:
id: 2
name: left_node
parent_id: 1
Right_Node:
id: 3
name: right_node
parent_id: 1


#2

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.