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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8b6f3bdd655ba2a19cda645e2150f34d?d=identicon&s=25 Dirk Breuer (Guest)
on 2006-01-05 14: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
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
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-01-05 17: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 Mornini
This topic is locked and can not be replied to.