Posted in Knowledge
The order of which we load fixtures to our tables will need to be defined when we use foreign key constraints on our tables.
These would likely be the errors when doing rake db:fixtures:load
rake aborted!
Mysql::Error: #23000Cannot delete or update a parent row: a foreign key constraint fails
Basically it’s because rake db:fixtures:load loads fixtures (empties the tables and inserts back) alphabetically.
Here is the solution (which works great) from Mr. Olesen.. Basically just write the order in your environment.rb :
ENV['FIXTURES'] ||= ‘accounts,developers,users’